Class StringArrayValidator
- java.lang.Object
-
- org.esa.snap.core.param.AbstractParamValidator
-
- org.esa.snap.core.param.validators.StringArrayValidator
-
- All Implemented Interfaces:
ParamValidator
public class StringArrayValidator extends AbstractParamValidator
-
-
Field Summary
-
Fields inherited from class org.esa.snap.core.param.AbstractParamValidator
_logger
-
-
Constructor Summary
Constructors Constructor Description StringArrayValidator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static String[]
castToStringArray(Object value)
boolean
equalValues(Parameter parameter, Object value1, Object value2)
Tests if the given two values are equal taking the given parameter information into account.String
format(Parameter parameter, Object value)
Returns the givenstring array
value as a string, according to the rules of theparameter
.protected static int
getValueSetIndex(String[] valueSet, String value, boolean caseSensitive)
int[]
getValueSetIndices(Parameter parameter)
Object
parse(Parameter parameter, String text)
Converts the given text into a value taking the given parameter information into account.void
validate(Parameter parameter, Object value)
Tests if the given value passes all constraints given in the supplied parameter information.protected void
validateThatValueIsAnAllowedEmptyValue(Parameter parameter, Object value)
-
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:ParamValidator
Converts the given text into a value taking the given parameter information into account.- Parameters:
parameter
- the parameter, must not benull
text
- 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 givenstring array
value as a string, according to the rules of theparameter
. If the value isnull
andnull value is allowed
, this method returns an empty string, otherwise aParamFormatException
will 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 isnull
andnull value is not allowed
or the value is not an instance ofString[]
.
-
validate
public void validate(Parameter parameter, Object value) throws ParamValidateException
Description copied from interface:ParamValidator
Tests if the given value passes all constraints given in the supplied parameter information. The value can also benull
since parameters can be allowed to have the value 'null'.- Parameters:
parameter
- the parameter, must not benull
value
- the value to be tested, can benull
- Throws:
ParamValidateException
-
validateThatValueIsAnAllowedEmptyValue
protected void validateThatValueIsAnAllowedEmptyValue(Parameter parameter, Object value) throws ParamValidateException
- Throws:
ParamValidateException
-
equalValues
public boolean equalValues(Parameter parameter, Object value1, Object value2)
Description copied from interface:ParamValidator
Tests if the given two values are equal taking the given parameter information into account.- Specified by:
equalValues
in interfaceParamValidator
- Overrides:
equalValues
in classAbstractParamValidator
- Parameters:
parameter
- the parameter, must not benull
value1
- the first value, can benull
value2
- the second value, can also benull
- Returns:
true
if the value are equal,false
otherwise
-
getValueSetIndices
public int[] getValueSetIndices(Parameter parameter)
-
-