com.conveyal.gtfs.validator.Validator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gtfs-lib Show documentation
Show all versions of gtfs-lib Show documentation
A library to load and index GTFS feeds of arbitrary size using disk-backed storage
package com.conveyal.gtfs.validator;
import com.conveyal.gtfs.error.NewGTFSError;
import com.conveyal.gtfs.error.NewGTFSErrorType;
import com.conveyal.gtfs.error.SQLErrorStorage;
import com.conveyal.gtfs.loader.Feed;
import com.conveyal.gtfs.model.Entity;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
/**
* A Validator examines a whole GTFS feed or a single trip within a GTFS feed. It accumulates error messages for
* problems it finds in that feed, optionally repairing the problems it encounters.
*/
public abstract class Validator {
Feed feed;
SQLErrorStorage errorStorage;
public Validator(Feed feed, SQLErrorStorage errorStorage) {
this.feed = feed;
this.errorStorage = errorStorage;
}
/**
* Store an error that affects the entire feed or an entire file. Wraps the underlying error constructor.
*/
// public void registerError (Class extends Entity> entityType, NewGTFSErrorType errorType) {
// errorStorage.storeError(new NewGTFSError(entityType, errorType));
// }
/**
* Store an error that affects a single line of a single table. Wraps the underlying error factory method.
*/
public void registerError(Entity entity, NewGTFSErrorType errorType) {
errorStorage.storeError(NewGTFSError.forEntity(entity, errorType));
}
// /**
// * Store an error that affects a single line of a single table. Add a single key-value pair to it. Wraps the
// * underlying error constructor.
// */
// public void registerError(Entity entity, NewGTFSErrorType errorType, String key, String value) {
// errorStorage.storeError(new NewGTFSError(entity, errorType).addInfo(key, value));
// }
/**
* Store an error that affects a single line of a single table.
* Add a bad value to it.
*/
public void registerError(Entity entity, NewGTFSErrorType errorType, Object badValue) {
errorStorage.storeError(NewGTFSError.forEntity(entity, errorType).setBadValue(badValue.toString()));
}
/**
* Basic storage of user-constructed error.
*/
public void registerError (NewGTFSError error) {
errorStorage.storeError(error);
}
/**
* This method will be called after the validation process is complete.
* This allows the implementation to perform any analysis or checking that uses accumulated information, and
* provides a path to output that summary information (by saving it in the provided ValidationResult object.
*/
public void complete (ValidationResult validationResult) {}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy