org.esa.beam.framework.param.validators
Class StringValidator

java.lang.Object
  extended by org.esa.beam.framework.param.AbstractParamValidator
      extended by org.esa.beam.framework.param.validators.StringValidator
All Implemented Interfaces:
ParamValidator
Direct Known Subclasses:
AbstractExpressionValidator

public class StringValidator
extends AbstractParamValidator


Field Summary
 
Fields inherited from class org.esa.beam.framework.param.AbstractParamValidator
_logger
 
Constructor Summary
StringValidator()
           
 
Method Summary
protected static String castToString(Object value)
           
static boolean equalValues(boolean caseSensitive, Object value1, Object value2)
           
 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 given string value as a string, according to the rules of the 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)
           
protected  void validateThatValueIsAnIdentifier(Parameter parameter, Object value)
           
protected  void validateThatValueIsAString(Parameter parameter, Object value)
           
 
Methods inherited from class org.esa.beam.framework.param.AbstractParamValidator
isAllowedNullText, isAllowedNullValue, isValueContainedInValueSet, validateThatNullValueIsAllowed, validateThatValueIsInValueSet, validateThatValuesAreInValueSet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringValidator

public StringValidator()
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 be null
text - the text to be converted into a value, must not be null
Returns:
the value represented by the text
Throws:
ParamParseException

format

public String format(Parameter parameter,
                     Object value)
              throws ParamFormatException
Returns the given string value as a string, according to the rules of the parameter. If the value is null and null value is allowed, this method returns an empty string, otherwise a ParamFormatException will be thrown.

Parameters:
parameter - the parameter which contains the rules to format
value - the value to format
Returns:
the value as string or an empty string.
Throws:
ParamFormatException - if the value is null and null value is not allowed or the value is not an instance of String.

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 be null since parameters can be allowed to have the value 'null'.

Parameters:
parameter - the parameter, must not be null
value - the value to be tested, can be null
Throws:
ParamValidateException

validateThatValueIsAString

protected void validateThatValueIsAString(Parameter parameter,
                                          Object value)
                                   throws ParamValidateException
Throws:
ParamValidateException

validateThatValueIsAnIdentifier

protected void validateThatValueIsAnIdentifier(Parameter parameter,
                                               Object value)
                                        throws ParamValidateException
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 interface ParamValidator
Overrides:
equalValues in class AbstractParamValidator
Parameters:
parameter - the parameter, must not be null
value1 - the first value, can be null
value2 - the second value, can also be null
Returns:
true if the value are equal, false otherwise

equalValues

public static boolean equalValues(boolean caseSensitive,
                                  Object value1,
                                  Object value2)

castToString

protected static String castToString(Object value)


Copyright © 2002-2012 Brockmann Consult GmbH. All Rights Reserved.