Class AbstractNumberIntervalValidator<T extends Number>
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.ametys.cms.contenttype.validation.AbstractContentValidator
org.ametys.cms.contenttype.validation.AbstractIntervalValidator<T>
org.ametys.cms.contenttype.validation.AbstractNumberIntervalValidator<T>
- Type Parameters:
T
- The numeric type tested by the validator.
- All Implemented Interfaces:
ContentValidator
,Configurable
,LogEnabled
- Direct Known Subclasses:
DoubleIntervalValidator
,LongIntervalValidator
public abstract class AbstractNumberIntervalValidator<T extends Number>
extends AbstractIntervalValidator<T>
Base
ContentValidator
validating the content by comparing one or more couples of numerical values.
For each couple of values, the identified max value should be greater than or equal to the identified min value.
The max and min values to compare are identified in validator's configuration by the metadata path as follows:
<min path="path/to/attribute/min"/>
<max path="path/to/attribute/max"/>
The path of attribute can contain one or more repeaters.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addErrorEmpty
(Errors errors, ElementDefinition minDefinition, ElementDefinition maxDefinition, I18nizableText emptyLabel) Add an error when the max or the min value is empty but the interval is mandatoryprotected void
addIntervalError
(Errors errors, ElementDefinition minDefinition, ElementDefinition maxDefinition, T min, T max) Add an error when the max value is less than the min valueprotected String
configureMaxPath
(Configuration configuration) Get the metadata max path from the configurationprotected String
configureMinPath
(Configuration configuration) Get the metadata min path from the configurationprotected boolean
isSupportedType
(ElementType type) Test if the attribute type is one expected by the validatorMethods inherited from class org.ametys.cms.contenttype.validation.AbstractIntervalValidator
_validateInterval, configure, isLessThan, validate, validate
Methods inherited from class org.ametys.cms.contenttype.validation.AbstractContentValidator
getContentType, setContentType
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Constructor Details
-
AbstractNumberIntervalValidator
public AbstractNumberIntervalValidator()
-
-
Method Details
-
configureMinPath
Description copied from class:AbstractIntervalValidator
Get the metadata min path from the configuration- Specified by:
configureMinPath
in classAbstractIntervalValidator<T extends Number>
- Parameters:
configuration
- The configuration- Returns:
- The metadata min path
- Throws:
ConfigurationException
- If an error occurs
-
configureMaxPath
Description copied from class:AbstractIntervalValidator
Get the metadata max path from the configuration- Specified by:
configureMaxPath
in classAbstractIntervalValidator<T extends Number>
- Parameters:
configuration
- The configuration- Returns:
- The metadata max path
- Throws:
ConfigurationException
- If an error occurs
-
isSupportedType
Description copied from class:AbstractIntervalValidator
Test if the attribute type is one expected by the validator- Specified by:
isSupportedType
in classAbstractIntervalValidator<T extends Number>
- Parameters:
type
- The attribute type- Returns:
- True if the type is supported
-
addIntervalError
protected void addIntervalError(Errors errors, ElementDefinition minDefinition, ElementDefinition maxDefinition, T min, T max) Description copied from class:AbstractIntervalValidator
Add an error when the max value is less than the min value- Specified by:
addIntervalError
in classAbstractIntervalValidator<T extends Number>
- Parameters:
errors
- The list of errorsminDefinition
- The min definitionmaxDefinition
- The max definitionmin
- The min valuemax
- The max value
-
addErrorEmpty
protected void addErrorEmpty(Errors errors, ElementDefinition minDefinition, ElementDefinition maxDefinition, I18nizableText emptyLabel) Description copied from class:AbstractIntervalValidator
Add an error when the max or the min value is empty but the interval is mandatory- Specified by:
addErrorEmpty
in classAbstractIntervalValidator<T extends Number>
- Parameters:
errors
- The list of errorsminDefinition
- The min definitionmaxDefinition
- The max definitionemptyLabel
- The label of the empty field
-