Package org.opengis.test
Class Validator
- java.lang.Object
-
- org.opengis.test.Validator
-
- Direct Known Subclasses:
GeometryValidator,MetadataValidator,NameValidator,ReferencingValidator
public abstract class Validator extends java.lang.ObjectBase class of all GeoAPI validators. Validators can be configured on a case-by-case basis by changing the values of non-final public fields. If the same configuration needs to be applied on all validators, thenValidatorContainer.allprovides a convenient way to make such change in a loop.Once the configuration is finished, all validators provided in GeoAPI are thread-safe provided that their configuration is not modified.
- Since:
- 2.2
- Version:
- 3.0
-
-
Field Summary
Fields Modifier and Type Field Description protected ValidatorContainercontainerThe container of this validator.protected static doubleDEFAULT_TOLERANCEThe default tolerance value for comparisons of floating point numbers.booleanenforceForbiddenAttributestrueif forbidden attributes are required to be null, orfalsefor tolerating non-null values.protected java.util.logging.LoggerloggerThe logger for reporting non-fatal warnings.booleanrequireMandatoryAttributestrueif mandatory attributes are required to be non-null, orfalsefor tolerating null values.
-
Constructor Summary
Constructors Modifier Constructor Description protectedValidator(ValidatorContainer container, java.lang.String packageName)Creates a new validator instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidforbidden(java.lang.String message, java.lang.Object value)Invoked when the existence of a forbidden attribute needs to be checked.protected voidmandatory(java.lang.String message, java.lang.Object value)Invoked when the existence of a mandatory attribute needs to be verified.
-
-
-
Field Detail
-
DEFAULT_TOLERANCE
protected static final double DEFAULT_TOLERANCE
The default tolerance value for comparisons of floating point numbers.- See Also:
- Constant Field Values
-
container
protected final ValidatorContainer container
The container of this validator.
-
logger
protected final java.util.logging.Logger logger
The logger for reporting non-fatal warnings.
-
requireMandatoryAttributes
public boolean requireMandatoryAttributes
trueif mandatory attributes are required to be non-null, orfalsefor tolerating null values. ISO specifications flags some attributes as mandatory, while some other are optional. Optional attributes are allowed to be null at any time, but mandatory attributes shall never be null - in theory. However implementors may choose to returnsnullon a temporary basis while they are developing their library. If this field is set tofalse, then missing mandatory attributes will be logged as warnings instead than causing a failure.The default value is
true.
-
enforceForbiddenAttributes
public boolean enforceForbiddenAttributes
trueif forbidden attributes are required to be null, orfalsefor tolerating non-null values. In ISO specifications, some attributes are declared as optional in parent class and specialized in subclasses, either as mandatory or as forbidden. If this field is set tofalse, then forbidden attributes will be logged as warnings instead than causing a failure.The default value is
true.
-
-
Constructor Detail
-
Validator
protected Validator(ValidatorContainer container, java.lang.String packageName)
Creates a new validator instance.- Parameters:
container- The container of this validator.packageName- The name of the package containing the classes to be validated.
-
-
Method Detail
-
mandatory
protected void mandatory(java.lang.String message, java.lang.Object value)Invoked when the existence of a mandatory attribute needs to be verified. If the given value isnull, then there is a choice:- If
requireMandatoryAttributesistrue(which is the default), then the test fails with the given message. - Otherwise, the message is logged as a warning and the test continues.
Subclasses can override this method if they want more control.
- Parameters:
message- The message to send in case of failure.value- The value to test for non-nullity.- See Also:
requireMandatoryAttributes
- If
-
forbidden
protected void forbidden(java.lang.String message, java.lang.Object value)Invoked when the existence of a forbidden attribute needs to be checked. If the given value is non-null, then there is a choice:- If
enforceForbiddenAttributesistrue(which is the default), then the test fails with the given message. - Otherwise, the message is logged as a warning and the test continues.
Subclasses can override this method if they want more control.
- Parameters:
message- The message to send in case of failure.value- The value to test for nullity.- See Also:
enforceForbiddenAttributes
- If
-
-