Package org.supercsv.cellprocessor
Class Token
- java.lang.Object
-
- org.supercsv.cellprocessor.CellProcessorAdaptor
-
- org.supercsv.cellprocessor.Token
-
- All Implemented Interfaces:
BoolCellProcessor
,CellProcessor
,DateCellProcessor
,DoubleCellProcessor
,LongCellProcessor
,StringCellProcessor
public class Token extends CellProcessorAdaptor implements BoolCellProcessor, 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
- Author:
- Kasper B. Graversen
-
-
Field Summary
-
Fields inherited from class org.supercsv.cellprocessor.CellProcessorAdaptor
next
-
-
Constructor Summary
Constructors Constructor Description Token(java.lang.Object token, java.lang.Object returnValue)
Constructs a new Token processor, which returns the supplied value if the token is encountered, otherwise it returns the input unchanged.Token(java.lang.Object token, java.lang.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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
execute(java.lang.Object value, CsvContext context)
This method is invoked by the framework when the processor needs to process data or check constraints.-
Methods inherited from class org.supercsv.cellprocessor.CellProcessorAdaptor
toString, validateInputNotNull
-
-
-
-
Constructor Detail
-
Token
public Token(java.lang.Object token, java.lang.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 tokenreturnValue
- the value to return if the token is encountered
-
Token
public Token(java.lang.Object token, java.lang.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 tokenreturnValue
- the value to return if the token is encounterednext
- the next processor in the chain- Throws:
java.lang.NullPointerException
- if next is null
-
-
Method Detail
-
execute
public java.lang.Object execute(java.lang.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 interfaceCellProcessor
- Parameters:
value
- the value to be processedcontext
- the CSV context- Returns:
- the result of cell processor execution
- Throws:
SuperCsvCellProcessorException
- if value is null
-
-