org.exolab.castor.xml.validators

Class NameValidator

Implemented Interfaces:
TypeValidator

public class NameValidator
extends StringValidator

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

Nested Class Summary

Nested classes/interfaces inherited from class org.exolab.castor.xml.validators.PatternValidator

PatternValidator.DefaultRegExpEvaluator

Field Summary

static short
CDATA
XML name type CDATA.
static short
NCNAME
XML name type NCName.
static short
NMTOKEN
XML name type NMTOKEN.

Constructor Summary

NameValidator()
Creates a new NameValidator with the default validation set to NCName.
NameValidator(short type)
Creates a new NameValidator with the given validation type.

Method Summary

void
setRequired(boolean required)
Sets whether or not a String is required (non null).
void
validate(Object object)
Validates the given Object.
void
validate(Object object, ValidationContext context)
Validates the given Object.
void
validate(String value, ValidationContext context)
Validates the given Object.

Methods inherited from class org.exolab.castor.xml.validators.StringValidator

clearFixed, normalize, setFixed, setFixedValue, setLength, setMaxLength, setMinLength, setRequired, setWhiteSpace, validate, validate, validate

Methods inherited from class org.exolab.castor.xml.validators.PatternValidator

addPattern, clearPatterns, getPattern, getPatterns, hasPattern, isNillable, setNillable, setPattern, validate, validate

Field Details

CDATA

public static final short CDATA
XML name type CDATA. @deprecated - use XMLConstants.NAME_TYPE_CDATA. Retained for backwards-compatility.
Field Value:
2

NCNAME

public static final short NCNAME
XML name type NCName. @deprecated - use XMLConstants.NAME_TYPE_NCNAME. Retained for backwards-compatility.
Field Value:
0

NMTOKEN

public static final short NMTOKEN
XML name type NMTOKEN. @deprecated - use XMLConstants.NAME_TYPE_NCTOKEN. Retained for backwards-compatility.
Field Value:
1

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:
setRequired in interface StringValidator
Parameters:
required - the flag indicating whether Strings are required

validate

public void validate(Object object)
            throws ValidationException
Validates the given Object.
Overrides:
validate in interface StringValidator
Parameters:
object - the Object to validate
Throws:
ValidationException - if the object fails validation.

validate

public void validate(Object object,
                     ValidationContext context)
            throws ValidationException
Validates the given Object.
Specified by:
validate in interface TypeValidator
Overrides:
validate in interface StringValidator
Parameters:
object - the Object to validate
context - the ValidationContext
Throws:
ValidationException - if the object fails validation.

validate

public void validate(String value,
                     ValidationContext context)
            throws ValidationException
Validates the given Object.
Overrides:
validate in interface StringValidator
Parameters:
value - the string to validate
context - the ValidationContext
Throws:
ValidationException - if the object fails validation.

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