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
-
Method Summary
Modifier and TypeMethodDescriptionprotected ParseState
determineState
(int symbolCharacter, EncounteredSymbol symbol) Determine state.int
Gets the current column.int
Gets the current line.Gets the symbol mapping.boolean
Ignore line.boolean
Checks if is empty line.boolean
Checks if is finished.boolean
Checks if is line finished.boolean
Checks if is token start.boolean
isTrash()
Checks if is trash.offerSymbol
(int symbolCharacter) Offer symbol.void
setSymbolMapping
(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
-