org.exolab.castor.xml.validators
Class StringValidator

java.lang.Object
  extended by org.exolab.castor.xml.validators.PatternValidator
      extended by org.exolab.castor.xml.validators.StringValidator
All Implemented Interfaces:
TypeValidator
Direct Known Subclasses:
NameValidator

public class StringValidator
extends PatternValidator
implements TypeValidator

The String Validation class

Version:
$Revision: 1.4 $ $Date: 2004/12/11 09:13:52 $
Author:
Keith Visco

Nested Class Summary
 
Nested classes/interfaces inherited from class org.exolab.castor.xml.validators.PatternValidator
PatternValidator.DefaultRegExpEvaluator
 
Constructor Summary
StringValidator()
          Creates a new StringValidator with no restrictions
 
Method Summary
 java.lang.String normalize(java.lang.String value)
          NOTE: THIS METHOD SHOULD NOT BE HERE..SHOULD BE MOVED TO A FieldHandler or to the Unmarshaller...but not here!!! (kvisco 20030125) Normalizes the given string according to the whiteSpace facet used
 void setFixed(java.lang.String fixedValue)
          Sets the fixed value in which all valid Strings must match.
 void setFixedValue(java.lang.String fixedValue)
          Deprecated. since 0.9.4_beta
 void setLength(int length)
          Sets the length that valid Strings must be
 void setMaxLength(int maxLength)
          Sets the maximum length of that a valid String must be.
 void setMinLength(int minLength)
          Sets the minimum length that valid Strings must be
 void setRequired(boolean required)
          Sets whether or not a String is required (non null)
 void setWhiteSpace(java.lang.String value)
          Sets the whiteSpace facet of the validator
 void validate(java.lang.Object object)
          Validates the given Object
 void validate(java.lang.Object object, ValidationContext context)
          Validates the given Object
 void validate(java.lang.String value, ValidationContext context)
          Validates the given String against the regular expression pattern of this PatternValidator.
 
Methods inherited from class org.exolab.castor.xml.validators.PatternValidator
getPattern, hasPattern, isNillable, setNillable, setPattern
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringValidator

public StringValidator()
Creates a new StringValidator with no restrictions

Method Detail

setFixed

public void setFixed(java.lang.String fixedValue)
Sets the fixed value in which all valid Strings must match.

Parameters:
fixedValue - the fixed value that all Strings must match

setFixedValue

public void setFixedValue(java.lang.String fixedValue)
Deprecated. since 0.9.4_beta

Only used for backward compatibility for object model generated with an old version of Castor


setMaxLength

public void setMaxLength(int maxLength)
Sets the maximum length of that a valid String must be. To remove the max length facet, use a negative value.

Parameters:
maxLength - the maximum length for valid Strings

setMinLength

public void setMinLength(int minLength)
Sets the minimum length that valid Strings must be

Parameters:
minLength - the minimum length that valid Strings must be

setLength

public void setLength(int length)
Sets the length that valid Strings must be

Parameters:
length - the length that valid Strings must be

setRequired

public void setRequired(boolean required)
Sets whether or not a String is required (non null)

Parameters:
required - the flag indicating whether Strings are required

setWhiteSpace

public void setWhiteSpace(java.lang.String value)

Sets the whiteSpace facet of the validator

The value of the whiteSpace facet must be one of the following:

any other value will generate a Warning and set the whiteSpace to preserved

Parameters:
whiteSpace - the whiteSpace value

normalize

public java.lang.String normalize(java.lang.String value)
NOTE: THIS METHOD SHOULD NOT BE HERE..SHOULD BE MOVED TO A FieldHandler or to the Unmarshaller...but not here!!! (kvisco 20030125) Normalizes the given string according to the whiteSpace facet used

Parameters:
value - the String to normalize

validate

public void validate(java.lang.String value,
                     ValidationContext context)
              throws ValidationException
Description copied from class: PatternValidator
Validates the given String against the regular expression pattern of this PatternValidator.

Overrides:
validate in class PatternValidator
Throws:
ValidationException - if the given String is not matched by the regular expression pattern
See Also:
PatternValidator.setPattern(java.lang.String)

validate

public void validate(java.lang.Object object)
              throws ValidationException
Validates the given Object

Parameters:
object - the Object to validate
Throws:
ValidationException

validate

public void validate(java.lang.Object object,
                     ValidationContext context)
              throws ValidationException
Validates the given Object

Specified by:
validate in interface TypeValidator
Overrides:
validate in class PatternValidator
Parameters:
object - the Object to validate
context - the ValidationContext
Throws:
ValidationException


Intalio Inc. (C) 1999-2004. All rights reserved http://www.intalio.com