Top Description Fields Constructors Methods
com.opencsv.validators

public Class RowValidatorAggregator

extends Object
Class Inheritance
Imports
com.opencsv.exceptions.CsvValidationException, java.util.ArrayList, .List

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.
Author
Scott Conway
Since
5.0

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
private List<RowValidator>

Constructor Summary

AccessConstructor and Description
public
RowValidatorAggregator()

Default constructor.

Method Summary

Modifier and TypeMethod and Description
public void
addValidator(RowValidator
Validator to be added.
validator
)

Add a validator to the aggregator.

public boolean

Returns:

true if all validators' RowValidator#isValid(String[]) methods return true, false otherwise.
isValid
(final String[]
Array of strings to be validated.
row
)

Runs all RowValidators' RowValidator#isValid(String[]) method against the line.

pack-priv void
setValidators(List<RowValidator>
- list of validators to use.
validators
)

Setter created for unit test.

public void
validate(String[]
Array of Strings to be validation.
row
)

Runs all RowValidators' RowValidator#validate(String[]) methods and if the string array is invalid, then it combines all the validation error messages in a single CsvValidationException.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CAPACITYback to summary
private static final int CAPACITY
MULTIPLIERback to summary
private static final int MULTIPLIER
validatorsback to summary
private List<RowValidator> validators

Constructor Detail

RowValidatorAggregatorback to summary
public RowValidatorAggregator()

Default constructor.

Method Detail

addValidatorback to summary
public void addValidator(RowValidator validator)

Add a validator to the aggregator.

Parameters
validator:RowValidator

Validator to be added.

isValidback to summary
public boolean isValid(final String[] row)

Runs all RowValidators' RowValidator#isValid(String[]) method against the line. This is a short circuit: as soon as one validator returns false then false is returned.

Parameters
row:String[]

Array of strings to be validated.

Returns:boolean

true if all validators' RowValidator#isValid(String[]) methods return true, false otherwise.

setValidatorsback to summary
pack-priv void setValidators(List<RowValidator> validators)

Setter created for unit test.

Parameters
validators:List<RowValidator>

- list of validators to use.

validateback to summary
public void validate(String[] row) throws CsvValidationException

Runs all RowValidators' 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:String[]

Array of Strings to be validation.

Exceptions
CsvValidationException:
Thrown if the string is invalid.