org.exolab.castor.xml.validators

Class StringValidator

public class StringValidator extends PatternValidator implements TypeValidator

The String Validation class

Version: $Revision: 6230 $ $Date: 2004-12-11 02:13:52 -0700 (Sat, 11 Dec 2004) $

Author: Keith Visco

Constructor Summary
StringValidator()
Creates a new StringValidator with no restrictions
Method Summary
Stringnormalize(String value)
NOTE: THIS METHOD SHOULD NOT BE HERE..SHOULD BE MOVED TO A FieldHandler or to the Unmarshaller...but not here!
voidsetFixed(String fixedValue)
Sets the fixed value in which all valid Strings must match.
voidsetFixedValue(String fixedValue)
Only used for backward compatibility for object model generated with an old version of Castor
voidsetLength(int length)
Sets the length that valid Strings must be
voidsetMaxLength(int maxLength)
Sets the maximum length of that a valid String must be.
voidsetMinLength(int minLength)
Sets the minimum length that valid Strings must be
voidsetRequired(boolean required)
Sets whether or not a String is required (non null)
voidsetWhiteSpace(String value)

Sets the whiteSpace facet of the validator

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

  • preserve
  • replace
  • collapse
any other value will generate a Warning and set the whiteSpace to preserved
voidvalidate(String value, ValidationContext context)
voidvalidate(Object object)
Validates the given Object
voidvalidate(Object object, ValidationContext context)
Validates the given Object

Constructor Detail

StringValidator

public StringValidator()
Creates a new StringValidator with no restrictions

Method Detail

normalize

public String normalize(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

setFixed

public void setFixed(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(String fixedValue)

Deprecated: since 0.9.4_beta

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

setLength

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

Parameters: length the length that valid Strings must be

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

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(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: value the whiteSpace value

validate

public void validate(String value, ValidationContext context)

validate

public void validate(Object object)
Validates the given Object

Parameters: object the Object to validate

validate

public void validate(Object object, ValidationContext context)
Validates the given Object

Parameters: object the Object to validate context the ValidationContext

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