View Javadoc
1   package com.opencsv.bean.processor;
2   
3   /**
4    * This is the interface for validators for a single
5    * {@link java.lang.String} value.
6    * <p>Currently this is used by the {@link PreAssignmentProcessor} to possibly
7    * modify the value of a string before time is taken to convert it.</p>
8    * <p>This can be used when modifying the setter of the bean is not possible.</p>
9    * <p>WARNING - using a processor can change the string in ways that could make
10   * it impossible to be processed or make it into a different format than what
11   * you are expecting based on the settings of the parser and reader. So great
12   * care must be taken when creating and using a StringProcessor.</p>
13   * <p>NOTE - Because of the potential problems a bad processor can cause we
14   * will close down any bug reports created for opencsv where a StringProcessor is
15   * involved with the recommendation they be reopened as a support request.</p>
16   *
17   * @author Scott Conway
18   * @since 5.0
19   */
20  public interface StringProcessor {
21      /**
22       * Method that contains the code that will transform a string into the
23       * value that will be validated and converted into the bean field.
24       *
25       * @param value {@link String} to be processed
26       * @return The processed {@link String}
27       */
28      String processString(String value);
29  
30      /**
31       * This allows the validator extending {@link StringProcessor} to be used
32       * by multiple fields by allowing you to pass in data for the processor to
33       * be used.
34       * <p>The data could be a default value or whatever the custom processor
35       * requires to convert the data.</p>
36       * <p>If the processor needs multiple parameters, then you will need to
37       * combine them into a single string using some sort of delimiter, say a
38       * comma, and parse them out using some library that allows you to parse
39       * such strings 😁.</p>
40       * <p>If the processor does not need a value then just create an empty
41       * method like the ConvertEmptyOrBlankStringsToNull processor used by the
42       * BeanFieldProcessorTest.</p>
43       *
44       * @param value Information used by the processor to process the string
45       */
46      void setParameterString(String value);
47  }