Top Description Fields Constructors Methods
com.opencsv.validators

public Class RowMustHaveSameNumberOfColumnsAsFirstRowValidator

extends Object
implements RowValidator
Class Inheritance
All Implemented Interfaces
com.opencsv.validators.RowValidator
Imports
com.opencsv.exceptions.CsvValidationException

This validator is used when the number of columns is not neccessarily known but must be consistent. The first row validated will always be considered valid, unless null or empty, and after that the each subsequent row must have the same number of columns as the first.

Arrays that are empty or null are considered to have 0 elements. An empty or null first row is considered invalid.

As with all row validators the assumption is you have control of the data and have skipped any initial empty lines. If you have data that has empty lines or separators lines in your data then you should not use this class. Either extend it or write your own validator.

Author
Scott Conway
Since
5.0

Field Summary

Modifier and TypeField and Description
private static final int
private int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private boolean
public boolean
isValid(String[] row)

Implements com.opencsv.validators.RowValidator.isValid.

Performs the validation check on the string and returns the result.

public void
validate(String[] row)

Implements com.opencsv.validators.RowValidator.validate.

Performs the validation check on the row (an array of Strings) and throws an exception if invalid.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

NO_ROWSback to summary
private static final int NO_ROWS
numRowsback to summary
private int numRows

Constructor Detail

RowMustHaveSameNumberOfColumnsAsFirstRowValidatorback to summary
public RowMustHaveSameNumberOfColumnsAsFirstRowValidator()

Default constructor.

Method Detail

firstRowNotSetYetback to summary
private boolean firstRowNotSetYet()
isValidback to summary
public boolean isValid(String[] row)

Implements com.opencsv.validators.RowValidator.isValid.

Doc from com.opencsv.validators.RowValidator.isValid.

Performs the validation check on the string and returns the result. While not called directly in opencsv it is in the interface to provide an easy way to test if the validator is functioning properly.

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

Implements com.opencsv.validators.RowValidator.validate.

Doc from com.opencsv.validators.RowValidator.validate.

Performs the validation check on the row (an array of Strings) and throws an exception if invalid.

Annotations
@Override
Exceptions
CsvValidationException:
Thrown if invalid. Should contain a message describing the error.