Class Token

All Implemented Interfaces:
BoolCellProcessor, CellProcessor, DateCellProcessor, DoubleCellProcessor, LongCellProcessor, StringCellProcessor

This processor is used in the situations you want to be able to check for the presence of a "special token". Such a token could be the string "[empty]" which could denote that a column is different from the empty string "".

For example, to convert the String "[empty]" to -1 (an int representing 'empty') you could use new Token("[empty]", -1)

Comparison between the input and the token is based on the object's equals() method.

Since:
1.02
  • Field Details

    • returnValue

      private final Object returnValue
    • token

      private final Object token
  • Constructor Details

    • Token

      public Token(Object token, Object returnValue)
      Constructs a new Token processor, which returns the supplied value if the token is encountered, otherwise it returns the input unchanged.
      Parameters:
      token - the token
      returnValue - the value to return if the token is encountered
    • Token

      public Token(Object token, Object returnValue, CellProcessor next)
      Constructs a new Token processor, which returns the supplied value if the token is encountered, otherwise it passes the input unchanged to the next processor in the chain.
      Parameters:
      token - the token
      returnValue - the value to return if the token is encountered
      next - the next processor in the chain
      Throws:
      NullPointerException - if next is null
  • Method Details

    • execute

      public Object execute(Object value, CsvContext context)
      This method is invoked by the framework when the processor needs to process data or check constraints.
      Specified by:
      execute in interface CellProcessor
      Parameters:
      value - the value to be processed
      context - the CSV context
      Returns:
      the result of cell processor execution
      Throws:
      SuperCsvCellProcessorException - if value is null