Class ParseStateMachine

java.lang.Object
org.csveed.token.ParseStateMachine

public class ParseStateMachine extends Object
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 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

      public String offerSymbol(int symbolCharacter) throws ParseException
      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 character
      symbol - the symbol
      Returns:
      the parses the state
      Throws:
      ParseException - the parse exception
    • setSymbolMapping

      public void setSymbolMapping(SymbolMapping symbolMapping)
      Sets the symbol mapping.
      Parameters:
      symbolMapping - the new symbol mapping
    • getSymbolMapping

      public SymbolMapping getSymbolMapping()
      Gets the symbol mapping.
      Returns:
      the symbol mapping