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
-
Field Summary
FieldsFields inherited from class org.supercsv.cellprocessor.CellProcessorAdaptor
next
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new Token processor, which returns the supplied value if the token is encountered, otherwise it returns the input unchanged.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. -
Method Summary
Modifier and TypeMethodDescriptionexecute
(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
-
Field Details
-
returnValue
-
token
-
-
Constructor Details
-
Token
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
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:
NullPointerException
- if next is null
-
-
Method Details
-
execute
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
-