public class CsvValidator extends Object
A typical invocation sequence:
Boolean failFast = false; List<Substitution> pathSubstitutions = new ArrayList<Substitution>(); //add a substitution path pathSubstitutions.add(new Substitution("file://something", "/home/xxx")); List<FailMessage> messages = CsvValidator.validate( "/home/dev/IdeaProjects/csv/csv-validator/csv-validator-core/data.csv", "/home/dev/IdeaProjects/csv/csv-validator/csv-validator-core/data-schema.csvs", failFast, pathSubstitutions, true); if(messages.isEmpty()) { System.out.println("All worked OK"); } else { for(FailMessage message : messages) { if(message instanceof WarningMessage) { System.out.println("Warning: " + message.getMessage()); } else { System.out.println("Error: " + message.getMessage()); } } }
| Constructor and Description |
|---|
CsvValidator() |
| Modifier and Type | Method and Description |
|---|---|
static List<FailMessage> |
validate(Reader csvData,
Reader csvSchema,
boolean failFast,
List<Substitution> pathSubstitutions,
Boolean enforceCaseSensitivePathChecks,
Boolean trace)
Validate CSV data against a CSV schema
|
static List<FailMessage> |
validate(Reader csvData,
Reader csvSchema,
boolean failFast,
List<Substitution> pathSubstitutions,
Boolean enforceCaseSensitivePathChecks,
Boolean trace,
ProgressCallback progress)
Validate CSV data against a CSV schema
|
static List<FailMessage> |
validate(String csvFilename,
Charset csvEncoding,
String csvSchemaFilename,
Charset csvSchemaEncoding,
boolean failFast,
List<Substitution> pathSubstitutions,
Boolean enforceCaseSensitivePathChecks,
Boolean trace)
Validate a CSV file against a CSV schema file
|
static List<FailMessage> |
validate(String csvFilename,
Charset csvEncoding,
String csvSchemaFilename,
Charset csvSchemaEncoding,
boolean failFast,
List<Substitution> pathSubstitutions,
Boolean enforceCaseSensitivePathChecks,
Boolean trace,
ProgressCallback progress)
Validate a CSV file against a CSV schema file
|
static List<FailMessage> |
validate(String csvFilename,
String csvSchemaFilename,
boolean failFast,
List<Substitution> pathSubstitutions,
Boolean enforceCaseSensitivePathChecks,
Boolean trace)
Validate a CSV file against a CSV schema file
Assumes that the encoding of the CSV file and
CSV Schema file are both UTF-8
|
static List<FailMessage> |
validate(String csvFilename,
String csvSchemaFilename,
boolean failFast,
List<Substitution> pathSubstitutions,
Boolean enforceCaseSensitivePathChecks,
Boolean trace,
ProgressCallback progress)
Validate a CSV file against a CSV schema file
Assumes that the encoding of the CSV file and
CSV Schema file are both UTF-8
|
public static List<FailMessage> validate(String csvFilename, String csvSchemaFilename, boolean failFast, List<Substitution> pathSubstitutions, Boolean enforceCaseSensitivePathChecks, Boolean trace)
csvFilename - filename of the CSV filecsvSchemaFilename - Filename of the CSV schema filefailFast - true if you want to stop processing on the first error found,
false if you want to fine all errorspathSubstitutions - list of substitutions for file pathsenforceCaseSensitivePathChecks - Enforces case-sensitive file path checkstrace - When set to true, a trace of the grammar parse will be outputpublic static List<FailMessage> validate(String csvFilename, Charset csvEncoding, String csvSchemaFilename, Charset csvSchemaEncoding, boolean failFast, List<Substitution> pathSubstitutions, Boolean enforceCaseSensitivePathChecks, Boolean trace)
csvFilename - filename of the CSV filecsvEncoding - The charset encoding used in the CSV filecsvSchemaFilename - Filename of the CSV schema filecsvSchemaEncoding - The charset encoding used in the CSV Schema filefailFast - true if you want to stop processing on the first error found,
false if you want to fine all errorspathSubstitutions - list of substitutions for file pathsenforceCaseSensitivePathChecks - Enforces case-sensitive file path checkstrace - When set to true, a trace of the grammar parse will be outputpublic static List<FailMessage> validate(String csvFilename, String csvSchemaFilename, boolean failFast, List<Substitution> pathSubstitutions, Boolean enforceCaseSensitivePathChecks, Boolean trace, ProgressCallback progress)
csvFilename - filename of the CSV filecsvSchemaFilename - Filename of the CSV schema filefailFast - true if you want to stop processing on the first error found,
false if you want to fine all errorspathSubstitutions - list of substitutions for file pathsenforceCaseSensitivePathChecks - Enforces case-sensitive file path checkstrace - When set to true, a trace of the grammar parse will be outputprogress - A callback to receive progress updates on the validation
processpublic static List<FailMessage> validate(String csvFilename, Charset csvEncoding, String csvSchemaFilename, Charset csvSchemaEncoding, boolean failFast, List<Substitution> pathSubstitutions, Boolean enforceCaseSensitivePathChecks, Boolean trace, ProgressCallback progress)
csvFilename - filename of the CSV filecsvEncoding - The charset encoding used in the CSV filecsvSchemaFilename - Filename of the CSV schema filecsvSchemaEncoding - The charset encoding used in the CSV Schema filefailFast - true if you want to stop processing on the first error found,
false if you want to fine all errorspathSubstitutions - list of substitutions for file pathsenforceCaseSensitivePathChecks - Enforces case-sensitive file path checkstrace - When set to true, a trace of the grammar parse will be outputprogress - A callback to receive progress updates on the validation
processpublic static List<FailMessage> validate(Reader csvData, Reader csvSchema, boolean failFast, List<Substitution> pathSubstitutions, Boolean enforceCaseSensitivePathChecks, Boolean trace)
csvData - CSV datacsvSchema - CSV schemafailFast - true if you want to stop processing on the first error found,
false if you want to fine all errorspathSubstitutions - list of substitutions for file pathsenforceCaseSensitivePathChecks - Enforces case-sensitive file path checkstrace - When set to true, a trace of the grammar parse will be outputpublic static List<FailMessage> validate(Reader csvData, Reader csvSchema, boolean failFast, List<Substitution> pathSubstitutions, Boolean enforceCaseSensitivePathChecks, Boolean trace, ProgressCallback progress)
csvData - CSV datacsvSchema - CSV schemafailFast - true if you want to stop processing on the first error found,
false if you want to fine all errorspathSubstitutions - list of substitutions for file pathsenforceCaseSensitivePathChecks - Enforces case-sensitive file path checkstrace - When set to true, a trace of the grammar parse will be outputprogress - A callback to receive progress updates on the validation
processCopyright © 2013-2017 The National Archives. All Rights Reserved