Interface StringProcessor


  • public interface StringProcessor
    This is the interface for validators for a single 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
    Author:
    Scott Conway
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.String processString​(java.lang.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​(java.lang.String value)
      This allows the validator extending StringProcessor to be used by multiple fields by allowing you to pass in data for the processor to be used.
    • Method Detail

      • processString

        java.lang.String processString​(java.lang.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.
        Parameters:
        value - String to be processed
        Returns:
        The processed String
      • setParameterString

        void setParameterString​(java.lang.String value)
        This allows the validator extending StringProcessor 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