java.lang.Object
org.csveed.token.ParseStateMachine
Yep, a state machine. Managing all kinds of booleans to form a pseudo-state doesn't work really well whereas a state
machine does. The state machine takes one character at a time, checks routes to the new state if necessary and holds
tokens, which it returns whenever a field-end ('popToken') has been found.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ParseStatedetermineState(int symbolCharacter, EncounteredSymbol symbol) Determine state.intGets the current column.intGets the current line.Gets the symbol mapping.booleanIgnore line.booleanChecks if is empty line.booleanChecks if is finished.booleanChecks if is line finished.booleanChecks if is token start.booleanisTrash()Checks if is trash.offerSymbol(int symbolCharacter) Offer symbol.voidsetSymbolMapping(SymbolMapping symbolMapping) Sets the symbol mapping.
-
Constructor Details
-
ParseStateMachine
public ParseStateMachine()
-
-
Method Details
-
getCurrentLine
public int getCurrentLine()Gets the current line.- Returns:
- the current line
-
getCurrentColumn
public int getCurrentColumn()Gets the current column.- Returns:
- the current column
-
isTrash
public boolean isTrash()Checks if is trash.- Returns:
- true, if is trash
-
offerSymbol
Offer symbol.- Parameters:
symbolCharacter- the symbol character- Returns:
- the string
- Throws:
ParseException- the parse exception
-
isTokenStart
public boolean isTokenStart()Checks if is token start.- Returns:
- true, if is token start
-
isLineFinished
public boolean isLineFinished()Checks if is line finished.- Returns:
- true, if is line finished
-
isFinished
public boolean isFinished()Checks if is finished.- Returns:
- true, if is finished
-
ignoreLine
public boolean ignoreLine()Ignore line.- Returns:
- true, if successful
-
isEmptyLine
public boolean isEmptyLine()Checks if is empty line.- Returns:
- true, if is empty line
-
determineState
protected ParseState determineState(int symbolCharacter, EncounteredSymbol symbol) throws ParseException Determine state.- Parameters:
symbolCharacter- the symbol charactersymbol- the symbol- Returns:
- the parses the state
- Throws:
ParseException- the parse exception
-
setSymbolMapping
Sets the symbol mapping.- Parameters:
symbolMapping- the new symbol mapping
-
getSymbolMapping
Gets the symbol mapping.- Returns:
- the symbol mapping
-