Class ForbidSubStr
java.lang.Object
org.supercsv.cellprocessor.CellProcessorAdaptor
org.supercsv.cellprocessor.constraint.ForbidSubStr
- All Implemented Interfaces:
CellProcessor, StringCellProcessor
Converts the input to a String and ensures that it doesn't contain any of the supplied substrings. For example, this
constraint might be handy when reading/writing filenames and wanting to ensure no filename contains ":", "/", etc.
- Since:
- 1.10
- Author:
- Kasper B. Graversen, James Bassett
-
Field Summary
Fields inherited from class CellProcessorAdaptor
next -
Constructor Summary
ConstructorsConstructorDescriptionForbidSubStr(String... forbiddenSubStrings) Constructs a new ForbidSubStr processor which ensures the input doesn't contain any of the supplied substrings.ForbidSubStr(String[] forbiddenSubStrings, CellProcessor next) Constructs a new ForbidSubStr processor which ensures the input doesn't contain any of the supplied substrings, then calls the next processor in the chain.ForbidSubStr(String forbiddenSubString, CellProcessor next) Constructs a new ForbidSubStr processor which ensures the input doesn't contain the supplied substring, then calls the next processor in the chain.ForbidSubStr(List<String> forbiddenSubStrings) Constructs a new ForbidSubStr processor which ensures the input doesn't contain any of the supplied substrings.ForbidSubStr(List<String> forbiddenSubStrings, CellProcessor next) Constructs a new ForbidSubStr processor which ensures the input doesn't contain any of the supplied substrings, then calls the next processor in the chain. -
Method Summary
Modifier and TypeMethodDescriptionexecute(Object value, CsvContext context) This method is invoked by the framework when the processor needs to process data or check constraints.Methods inherited from class CellProcessorAdaptor
toString, validateInputNotNull
-
Constructor Details
-
ForbidSubStr
Constructs a new ForbidSubStr processor which ensures the input doesn't contain any of the supplied substrings.- Parameters:
forbiddenSubStrings- the List of forbidden substrings- Throws:
NullPointerException- if forbiddenSubStrings or one of its elements is nullIllegalArgumentException- if forbiddenSubStrings is empty
-
ForbidSubStr
Constructs a new ForbidSubStr processor which ensures the input doesn't contain any of the supplied substrings.- Parameters:
forbiddenSubStrings- the forbidden substrings- Throws:
NullPointerException- if forbiddenSubStrings or one of its elements is nullIllegalArgumentException- if forbiddenSubStrings is empty
-
ForbidSubStr
Constructs a new ForbidSubStr processor which ensures the input doesn't contain any of the supplied substrings, then calls the next processor in the chain.- Parameters:
forbiddenSubStrings- the List of forbidden substringsnext- the next processor in the chain- Throws:
NullPointerException- if forbiddenSubStrings, one of its elements or next is nullIllegalArgumentException- if forbiddenSubStrings is empty
-
ForbidSubStr
Constructs a new ForbidSubStr processor which ensures the input doesn't contain the supplied substring, then calls the next processor in the chain.- Parameters:
forbiddenSubString- the forbidden substringnext- the next processor in the chain- Throws:
NullPointerException- if forbiddenSubString or next is null
-
ForbidSubStr
Constructs a new ForbidSubStr processor which ensures the input doesn't contain any of the supplied substrings, then calls the next processor in the chain.- Parameters:
forbiddenSubStrings- the forbidden substringsnext- the next processor in the chain- Throws:
NullPointerException- if forbiddenSubStrings, one of its elements or next is nullIllegalArgumentException- if forbiddenSubStrings is empty
-
-
Method Details
-
execute
This method is invoked by the framework when the processor needs to process data or check constraints.- Specified by:
executein 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 is in the forbidden list
-