Class StrRegEx

    • Constructor Summary

      Constructors 
      Constructor Description
      StrRegEx​(java.lang.String regex)
      Constructs a new StrRegEx processor, which ensures that the input data matches the given regular expression.
      StrRegEx​(java.lang.String regex, StringCellProcessor next)
      Constructs a new StrRegEx processor, which ensures that the input data matches the given regular expression, then calls the next processor in the chain.
    • Method Summary

      All Methods Static 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.
      static void registerMessage​(java.lang.String regex, java.lang.String message)
      Register a message detailing in plain language the constraint representing a regular expression.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • StrRegEx

        public StrRegEx​(java.lang.String regex)
        Constructs a new StrRegEx processor, which ensures that the input data matches the given regular expression.
        Parameters:
        regex - the regular expression to match
        Throws:
        java.lang.NullPointerException - if regex is null
        java.lang.IllegalArgumentException - if regex is empty
        java.util.regex.PatternSyntaxException - if regex is not a valid regular expression
      • StrRegEx

        public StrRegEx​(java.lang.String regex,
                        StringCellProcessor next)
        Constructs a new StrRegEx processor, which ensures that the input data matches the given regular expression, then calls the next processor in the chain.
        Parameters:
        regex - the regular expression to match
        next - the next processor in the chain
        Throws:
        java.lang.NullPointerException - if regex is null
        java.lang.IllegalArgumentException - if regex is empty
        java.util.regex.PatternSyntaxException - if regex is not a valid regular expression
    • 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 interface CellProcessor
        Parameters:
        value - the value to be processed
        context - the CSV context
        Returns:
        the result of cell processor execution
        Throws:
        SuperCsvCellProcessorException - if value is null
        SuperCsvConstraintViolationException - if value doesn't match the regular expression
      • registerMessage

        public static void registerMessage​(java.lang.String regex,
                                           java.lang.String message)
        Register a message detailing in plain language the constraint representing a regular expression. For example, the regular expression \d{0,6}(\.\d{0,3})? could be associated with the message "up to 6 digits whole digits, followed by up to 3 fractional digits".
        Parameters:
        regex - the regular expression
        message - the message to associate with the regex