Package com.crawljax.core.state
Class StateMachine
- java.lang.Object
-
- com.crawljax.core.state.StateMachine
-
public class StateMachine extends Object
The State Machine.
-
-
Field Summary
Fields Modifier and Type Field Description private StateVertexcurrentStateprivate StateVertexinitialStateprivate ConditionTypeChecker<Invariant>invariantCheckerThe invariantChecker to use when updating the state machine.private static org.slf4j.LoggerLOGGERprivate List<StateVertex>onURLSetprivate Pluginspluginsprivate StateComparatorstateComparatorprivate InMemoryStateFlowGraphstateFlowGraph
-
Constructor Summary
Constructors Constructor Description StateMachine(InMemoryStateFlowGraph sfg, com.google.common.collect.ImmutableList<Invariant> invariantList, Plugins plugins, StateComparator stateComparator, List<StateVertex> onURLSet)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private StateVertexaddStateToCurrentState(StateVertex newState, Eventable eventable)Adds the newState and the edge between the currentState and the newState on the SFG.booleanchangeState(StateVertex nextState)Change the currentState to the nextState if possible.StateVertexgetCurrentState()Return the current State in this state machine.List<StateVertex>getOnURLSet()InMemoryStateFlowGraphgetStateFlowGraph()StateVertexnewStateFor(EmbeddedBrowser browser)voidrewind()reset the state machine to the initial state.voidrunOnInvariantViolationPlugins(CrawlerContext context)voidsetCurrentState(StateVertex currentState)booleanswitchToStateAndCheckIfClone(Eventable event, StateVertex newState, CrawlerContext context)Adds an edge between the current and new state.
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
stateFlowGraph
private final InMemoryStateFlowGraph stateFlowGraph
-
initialState
private final StateVertex initialState
-
invariantChecker
private final ConditionTypeChecker<Invariant> invariantChecker
The invariantChecker to use when updating the state machine.
-
plugins
private final Plugins plugins
-
stateComparator
private final StateComparator stateComparator
-
currentState
private StateVertex currentState
-
onURLSet
private List<StateVertex> onURLSet
-
-
Constructor Detail
-
StateMachine
public StateMachine(InMemoryStateFlowGraph sfg, com.google.common.collect.ImmutableList<Invariant> invariantList, Plugins plugins, StateComparator stateComparator, List<StateVertex> onURLSet)
-
-
Method Detail
-
newStateFor
public StateVertex newStateFor(EmbeddedBrowser browser)
-
changeState
public boolean changeState(StateVertex nextState)
Change the currentState to the nextState if possible. The next state should already be present in the graph.- Parameters:
nextState- the next state.- Returns:
- true if currentState is successfully changed.
-
addStateToCurrentState
private StateVertex addStateToCurrentState(StateVertex newState, Eventable eventable)
Adds the newState and the edge between the currentState and the newState on the SFG.- Parameters:
newState- the new state.eventable- the clickable causing the new state.- Returns:
- the clone state iff newState is a clone, else returns null
-
getCurrentState
public StateVertex getCurrentState()
Return the current State in this state machine.- Returns:
- the current State.
-
setCurrentState
public void setCurrentState(StateVertex currentState)
-
rewind
public void rewind()
reset the state machine to the initial state.
-
switchToStateAndCheckIfClone
public boolean switchToStateAndCheckIfClone(Eventable event, StateVertex newState, CrawlerContext context)
Adds an edge between the current and new state.- Returns:
- true if the new state is not found in the state machine.
-
runOnInvariantViolationPlugins
public void runOnInvariantViolationPlugins(CrawlerContext context)
-
getOnURLSet
public List<StateVertex> getOnURLSet()
-
getStateFlowGraph
public InMemoryStateFlowGraph getStateFlowGraph()
-
-