Package pl.put.poznan.sqc.domain
Class SQCService
- java.lang.Object
-
- pl.put.poznan.sqc.domain.SQCService
-
public class SQCService extends Object
A service that contains the application's state (a scenario) and provides access to the app's various functionalities (visitors) via public methods.- See Also:
Scenario
,StepCounter
,KeywordCounter
-
-
Constructor Summary
Constructors Constructor Description SQCService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HashMap<String,Integer>
getActorCountMap()
Runs a ActorCount visitor on the stored scenario.ArrayList<String>
getActorlessSteps()
Runs a ActorlessAccumulator visitor on the stored scenario.int
getKeywordCount()
Runs a KeywordCounter visitor on the stored scenario.ArrayList<String>
getLonelyActorsList()
Runs a ActorCount visitor on the stored scenario.int
getStepCount()
Runs a StepCounter visitor on the stored scenario.String
getToDepth(int depth)
Get scenario as JSON, but only upto a certain depth.boolean
hasScenario()
Tests if there is a scenario loaded.void
removeScenario()
Deletes the stored scenario.void
setScenario(String jsonString)
Sets a scenario based on a String.void
setScenario(Scenario scenario)
Sets a scenario based on a Scenario class.
-
-
-
Method Detail
-
setScenario
public void setScenario(Scenario scenario)
Sets a scenario based on a Scenario class.- Parameters:
scenario
- the scenario (as a Scenario instance) that will be stored as the application's state.- See Also:
Scenario
,setScenario(String)
,getScenario()
-
setScenario
public void setScenario(String jsonString) throws InvalidScenarioException, org.json.simple.parser.ParseException
Sets a scenario based on a String.- Parameters:
jsonString
- the scenario (as a stringified JSON) that will be stored as the application's state (it will be converted to a Scenario object).- Throws:
InvalidScenarioException
org.json.simple.parser.ParseException
- See Also:
Scenario
,JSONConverter
,setScenario(Scenario)
,getScenario()
-
hasScenario
public boolean hasScenario()
Tests if there is a scenario loaded.- Returns:
- true if the SQCService has a scenario set | false
- See Also:
getScenario()
,setScenario(Scenario)
,setScenario(String)
-
removeScenario
public void removeScenario()
Deletes the stored scenario.
-
getStepCount
public int getStepCount() throws MissingScenarioError
Runs a StepCounter visitor on the stored scenario.- Returns:
- the number of steps in the stored scenario.
- Throws:
MissingScenarioError
- if no scenario is stored- See Also:
StepCounter
-
getKeywordCount
public int getKeywordCount() throws MissingScenarioError
Runs a KeywordCounter visitor on the stored scenario.- Returns:
- the number of keywords in the stored scenario.
- Throws:
MissingScenarioError
- if no scenario is stored- See Also:
KeywordCounter
-
getActorlessSteps
public ArrayList<String> getActorlessSteps() throws MissingScenarioError
Runs a ActorlessAccumulator visitor on the stored scenario.- Returns:
- a list of step texts where no actor begins the step.
- Throws:
MissingScenarioError
- if no scenario is stored- See Also:
ActorlessAccumulator
-
getActorCountMap
public HashMap<String,Integer> getActorCountMap() throws MissingScenarioError
Runs a ActorCount visitor on the stored scenario.- Throws:
MissingScenarioError
- if no scenario is stored- See Also:
ActorCount
-
getLonelyActorsList
public ArrayList<String> getLonelyActorsList() throws MissingScenarioError
Runs a ActorCount visitor on the stored scenario.- Returns:
- a map of: actor → number of steps in which they take part
- Throws:
MissingScenarioError
- if no scenario is stored- See Also:
ActorCount
-
getToDepth
public String getToDepth(int depth) throws MissingScenarioError
Get scenario as JSON, but only upto a certain depth.- Parameters:
depth
- the depth- Returns:
- the JSON
- Throws:
MissingScenarioError
- if no scenario is stored
-
-