Package org.opengis.test
Class Validator
java.lang.Object
org.opengis.test.Validator
- Direct Known Subclasses:
GeometryValidator
,MetadataValidator
,NameValidator
,ReferencingValidator
Base 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, then
ValidatorContainer.all
provides 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
FieldsModifier and TypeFieldDescriptionprotected final ValidatorContainer
The container of this validator.protected static final double
The default tolerance value for comparisons of floating point numbers.boolean
true
if forbidden attributes are required to be null, orfalse
for tolerating non-null values.protected final Logger
The logger for reporting non-fatal warnings.boolean
true
if mandatory attributes are required to be non-null, orfalse
for tolerating null values. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Validator
(ValidatorContainer container, String packageName) Creates a new validator instance. -
Method Summary
-
Field Details
-
DEFAULT_TOLERANCE
protected static final double DEFAULT_TOLERANCEThe default tolerance value for comparisons of floating point numbers.- See Also:
-
container
The container of this validator. -
logger
The logger for reporting non-fatal warnings. -
requireMandatoryAttributes
public boolean requireMandatoryAttributestrue
if mandatory attributes are required to be non-null, orfalse
for 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 returnsnull
on 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
.- See Also:
-
enforceForbiddenAttributes
public boolean enforceForbiddenAttributestrue
if forbidden attributes are required to be null, orfalse
for 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
.- See Also:
-
-
Constructor Details
-
Validator
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 Details
-
mandatory
Invoked when the existence of a mandatory attribute needs to be verified. If the given value isnull
, then there is a choice:- If
requireMandatoryAttributes
istrue
(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:
- If
-
forbidden
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
enforceForbiddenAttributes
istrue
(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:
- If
-