Interface StringProcessor
- All Known Implementing Classes:
ConvertEmptyOrBlankStringsToDefault
,ConvertEmptyOrBlankStringsToNull
,ConvertWordNullToNull
String
value.
Currently this is used by the PreAssignmentProcessor
to possibly
modify the value of a string before time is taken to convert it.
This can be used when modifying the setter of the bean is not possible.
WARNING - using a processor can change the string in ways that could make it impossible to be processed or make it into a different format than what you are expecting based on the settings of the parser and reader. So great care must be taken when creating and using a StringProcessor.
NOTE - Because of the potential problems a bad processor can cause we will close down any bug reports created for opencsv where a StringProcessor is involved with the recommendation they be reopened as a support request.
- Since:
- 5.0
-
Method Summary
Modifier and TypeMethodDescriptionprocessString
(String value) Method that contains the code that will transform a string into the value that will be validated and converted into the bean field.void
setParameterString
(String value) This allows the validator extendingStringProcessor
to be used by multiple fields by allowing you to pass in data for the processor to be used.
-
Method Details
-
processString
Method that contains the code that will transform a string into the value that will be validated and converted into the bean field. -
setParameterString
This allows the validator extendingStringProcessor
to be used by multiple fields by allowing you to pass in data for the processor to be used.The data could be a default value or whatever the custom processor requires to convert the data.
If the processor needs multiple parameters, then you will need to combine them into a single string using some sort of delimiter, say a comma, and parse them out using some library that allows you to parse such strings 😁.
If the processor does not need a value then just create an empty method like the ConvertEmptyOrBlankStringsToNull processor used by the BeanFieldProcessorTest.
- Parameters:
value
- Information used by the processor to process the string
-