Package com.opencsv.validators
Class RowValidatorAggregator
java.lang.Object
com.opencsv.validators.RowValidatorAggregator
The aggregator's purpose is to collect multiple
RowValidators and
run them against a single array of strings.
This way complex validations can be performed.- Since:
- 5.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate static final intprivate List<RowValidator> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddValidator(RowValidator validator) Add a validator to the aggregator.booleanRuns allRowValidators'RowValidator.isValid(String[])method against the line.(package private) voidsetValidators(List<RowValidator> validators) Setter created for unit test.voidRuns allRowValidators'RowValidator.validate(String[])methods and if the string array is invalid, then it combines all the validation error messages in a single CsvValidationException.
-
Field Details
-
CAPACITY
private static final int CAPACITY- See Also:
-
MULTIPLIER
private static final int MULTIPLIER- See Also:
-
validators
-
-
Constructor Details
-
RowValidatorAggregator
public RowValidatorAggregator()Default constructor.
-
-
Method Details
-
addValidator
Add a validator to the aggregator.- Parameters:
validator- Validator to be added.
-
isValid
Runs allRowValidators'RowValidator.isValid(String[])method against the line. This is a short circuit: as soon as one validator returnsfalsethenfalseis returned.- Parameters:
row- Array of strings to be validated.- Returns:
trueif all validators'RowValidator.isValid(String[])methods returntrue,falseotherwise.
-
validate
Runs allRowValidators'RowValidator.validate(String[])methods and if the string array is invalid, then it combines all the validation error messages in a single CsvValidationException.- Parameters:
row- Array of Strings to be validation.- Throws:
CsvValidationException- Thrown if the string is invalid.
-
setValidators
Setter created for unit test.- Parameters:
validators- - list of validators to use.
-