Class NumberValidator
- java.lang.Object
-
- org.esa.snap.core.param.AbstractParamValidator
-
- org.esa.snap.core.param.validators.NumberValidator
-
- All Implemented Interfaces:
ParamValidator
public class NumberValidator extends AbstractParamValidator
-
-
Field Summary
-
Fields inherited from class org.esa.snap.core.param.AbstractParamValidator
_logger
-
-
Constructor Summary
Constructors Constructor Description NumberValidator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static NumbercastToNumber(Object value)booleanequalValues(Parameter parameter, Object value1, Object value2)Compares two parameter values for equality.Stringformat(Parameter parameter, Object value)protected voidhandleOutOfRangeError(Parameter parameter)Objectparse(Parameter parameter, String text)Converts the given text into a value taking the given parameter information into account.voidvalidate(Parameter parameter, Object value)Tests if the given value passes all constraints given in the supplied parameter information.-
Methods inherited from class org.esa.snap.core.param.AbstractParamValidator
isAllowedNullText, isAllowedNullValue, isValueContainedInValueSet, validateThatNullValueIsAllowed, validateThatValueIsInValueSet, validateThatValuesAreInValueSet
-
-
-
-
Method Detail
-
parse
public Object parse(Parameter parameter, String text) throws ParamParseException
Description copied from interface:ParamValidatorConverts the given text into a value taking the given parameter information into account.- Parameters:
parameter- the parameter, must not benulltext- the text to be converted into a value, must not benull- Returns:
- the value represented by the text
- Throws:
ParamParseException
-
format
public String format(Parameter parameter, Object value) throws ParamFormatException
Returns the givennumbervalue as a string, according to the rules of theparameter. If the value isnullandnull value is allowed, this method returns an empty string, otherwise aParamFormatExceptionwill be thrown.- Parameters:
parameter- the parameter which contains the rules to formatvalue- the value to format- Returns:
- the value as string or an empty string.
- Throws:
ParamFormatException- if the value isnullandnull value is not allowedor the value is not an instance ofNumber.
-
validate
public void validate(Parameter parameter, Object value) throws ParamValidateException
Description copied from interface:ParamValidatorTests if the given value passes all constraints given in the supplied parameter information. The value can also benullsince parameters can be allowed to have the value 'null'.- Parameters:
parameter- the parameter, must not benullvalue- the value to be tested, can benull- Throws:
ParamValidateException
-
equalValues
public boolean equalValues(Parameter parameter, Object value1, Object value2)
Compares two parameter values for equality. It is assumed that both objects passed in as parametrer are numbers.- Specified by:
equalValuesin interfaceParamValidator- Overrides:
equalValuesin classAbstractParamValidator- Parameters:
parameter- not used in this contextvalue1- first value to be comparedvalue2- second value to be compared- Returns:
trueif the value are equal,falseotherwise
-
handleOutOfRangeError
protected void handleOutOfRangeError(Parameter parameter) throws ParamValidateException
- Throws:
ParamValidateException
-
-