Class NameValidator
java.lang.Object
org.exolab.castor.xml.validators.PatternValidator
org.exolab.castor.xml.validators.StringValidator
org.exolab.castor.xml.validators.NameValidator
- All Implemented Interfaces:
TypeValidator
The Name Validation class. This class handles validation for XML Name
production types such as NCName and NMToken
- Version:
- $Revision: 6605 $ $Date: 2005-12-13 14:58:48 -0700 (Tue, 13 Dec 2005) $
- Author:
- Keith Visco
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final shortXML name type CDATA.static final shortXML name type NCName.static final shortXML name type NMTOKEN.Fields inherited from class PatternValidator
resourceBundle -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new NameValidator with the default validation set to NCName.NameValidator(short type) Creates a new NameValidator with the given validation type. -
Method Summary
Modifier and TypeMethodDescriptionvoidsetRequired(boolean required) Sets whether or not a String is required (non null).voidValidates the given Object.voidvalidate(Object object, ValidationContext context) Validates the given Object.voidvalidate(String value, ValidationContext context) Validates the given Object.Methods inherited from class StringValidator
clearFixed, normalize, setFixed, setFixedValue, setLength, setMaxLength, setMinLength, setWhiteSpaceModifier and TypeMethodDescriptionvoidClears the fixed value for this ShortValidator.Normalizes the given string according to the whiteSpace facet used.voidSets the fixed value in which all valid Strings must match.voidsetFixedValue(String fixedValue) Deprecated.since 0.9.4_betavoidsetLength(int length) Sets the required string length for String validation.voidsetMaxLength(int maxLength) Sets the maximum string length for String validation.voidsetMinLength(int minLength) Sets the minimum string length for String validation.voidsetWhiteSpace(String value) Sets the whiteSpace facet of the validator.Methods inherited from class PatternValidator
addPattern, clearPatterns, getPatterns, hasPattern, isNillable, setNillableModifier and TypeMethodDescriptionvoidaddPattern(String pattern) Sets the regular expression to validate against.voidClear all configured patterns.Returns the collection of regular expression patterns.booleanReturns true if a regular expression has been set for this PatternValidator.booleanReturns whether or not objects validated by this Validator are nillable (are allowed to be null).voidsetNillable(boolean nillable) Sets whether or not objects validated by this Validator are allowed to be null (nillable).
-
Field Details
-
NCNAME
public static final short NCNAMEXML name type NCName. @deprecated - use XMLConstants.NAME_TYPE_NCNAME. Retained for backwards-compatility.- See Also:
-
NMTOKEN
public static final short NMTOKENXML name type NMTOKEN. @deprecated - use XMLConstants.NAME_TYPE_NCTOKEN. Retained for backwards-compatility.- See Also:
-
CDATA
public static final short CDATAXML name type CDATA. @deprecated - use XMLConstants.NAME_TYPE_CDATA. Retained for backwards-compatility.- See Also:
-
-
Constructor Details
-
NameValidator
public NameValidator()Creates a new NameValidator with the default validation set to NCName. -
NameValidator
public NameValidator(short type) Creates a new NameValidator with the given validation type.- Parameters:
type- the validation type for this NameValidator
-
-
Method Details
-
setRequired
public void setRequired(boolean required) Sets whether or not a String is required (non null).- Overrides:
setRequiredin classStringValidator- Parameters:
required- the flag indicating whether Strings are required
-
validate
Validates the given Object.- Overrides:
validatein classStringValidator- Parameters:
value- the string to validatecontext- the ValidationContext- Throws:
ValidationException- if the object fails validation.- See Also:
-
validate
Validates the given Object.- Overrides:
validatein classStringValidator- Parameters:
object- the Object to validate- Throws:
ValidationException- if the object fails validation.
-
validate
Validates the given Object.- Specified by:
validatein interfaceTypeValidator- Overrides:
validatein classStringValidator- Parameters:
object- the Object to validatecontext- the ValidationContext- Throws:
ValidationException- if the object fails validation.
-