Class StrRegEx
- java.lang.Object
-
- org.supercsv.cellprocessor.CellProcessorAdaptor
-
- org.supercsv.cellprocessor.constraint.StrRegEx
-
- All Implemented Interfaces:
CellProcessor
,StringCellProcessor
public class StrRegEx extends CellProcessorAdaptor implements StringCellProcessor
This constraint ensures that the input data matches the given regular expression.- Since:
- 1.50
- Author:
- Dominique De Vito, James Bassett
-
-
Field Summary
-
Fields inherited from class org.supercsv.cellprocessor.CellProcessorAdaptor
next
-
-
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 org.supercsv.cellprocessor.CellProcessorAdaptor
toString, validateInputNotNull
-
-
-
-
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 nulljava.lang.IllegalArgumentException
- if regex is emptyjava.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 matchnext
- the next processor in the chain- Throws:
java.lang.NullPointerException
- if regex is nulljava.lang.IllegalArgumentException
- if regex is emptyjava.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 interfaceCellProcessor
- Parameters:
value
- the value to be processedcontext
- the CSV context- Returns:
- the result of cell processor execution
- Throws:
SuperCsvCellProcessorException
- if value is nullSuperCsvConstraintViolationException
- 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 expressionmessage
- the message to associate with the regex
-
-