Package org.exolab.castor.xml
Class FieldValidator
- java.lang.Object
-
- org.exolab.castor.xml.Validator
-
- org.exolab.castor.xml.FieldValidator
-
- All Implemented Interfaces:
TypeValidator
,ClassValidator
public class FieldValidator extends Validator
Handles field validation.- Version:
- $Revision: 8617 $ $Date: 2004-10-08 22:58:55 -0600 (Fri, 08 Oct 2004) $
- Author:
- Keith Visco
-
-
Field Summary
-
Fields inherited from class org.exolab.castor.xml.Validator
resourceBundle
-
-
Constructor Summary
Constructors Constructor Description FieldValidator()
Creates a default FieldValidator.FieldValidator(TypeValidator validator)
Creates a new FieldValidator using the given TypeValidator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getMaxOccurs()
Returns the maximum number of occurances for a given object.int
getMinOccurs()
Returns the mimimum number of occurances for a given object.TypeValidator
getTypeValidator()
Returns the TypeValidator.boolean
hasTypeValidator()
Returns true if a TypeValidator has been set.void
setDescriptor(XMLFieldDescriptor descriptor)
Sets the field descriptor to use for obtaining information about the field to validate, such as the field name, the field handler, etc.void
setMaxOccurs(int maxOccurs)
Sets the maximum number of occurances for a given object.void
setMinOccurs(int minOccurs)
Sets the mimimum number of occurances for a given object.void
setValidator(TypeValidator validator)
void
validate(java.lang.Object object, ValidationContext context)
Validates the given Object.-
Methods inherited from class org.exolab.castor.xml.Validator
checkUnresolvedIdrefs, validate
-
-
-
-
Constructor Detail
-
FieldValidator
public FieldValidator()
Creates a default FieldValidator.
-
FieldValidator
public FieldValidator(TypeValidator validator)
Creates a new FieldValidator using the given TypeValidator.- Parameters:
validator
- the TypeValidator to delegate validation to
-
-
Method Detail
-
getMinOccurs
public int getMinOccurs()
Returns the mimimum number of occurances for a given object.- Returns:
- The mimimum number of occurances for a given object. A zero value denotes no lower bound (ie. the object is optional).
-
getMaxOccurs
public int getMaxOccurs()
Returns the maximum number of occurances for a given object.- Returns:
- The maximum number of occurances for a given object. A negative value denotes no upper bound.
-
getTypeValidator
public TypeValidator getTypeValidator()
Returns the TypeValidator.- Returns:
- the TypeValidator.
-
hasTypeValidator
public boolean hasTypeValidator()
Returns true if a TypeValidator has been set.- Returns:
- true if a TypeValidator has been set.
-
setMinOccurs
public void setMinOccurs(int minOccurs)
Sets the mimimum number of occurances for a given object. A zero, or negative value denotes no lower bound (i.e., the object is optional).- Parameters:
minOccurs
- the minimum number of times an object must occur in order to be valid.
-
setMaxOccurs
public void setMaxOccurs(int maxOccurs)
Sets the maximum number of occurances for a given object. A negative value denotes no upper bound.- Parameters:
maxOccurs
- the maximum number of times an object may occur.
-
setDescriptor
public void setDescriptor(XMLFieldDescriptor descriptor)
Sets the field descriptor to use for obtaining information about the field to validate, such as the field name, the field handler, etc.- Parameters:
descriptor
- the field descriptor for the field to validate
-
setValidator
public void setValidator(TypeValidator validator)
-
validate
public void validate(java.lang.Object object, ValidationContext context) throws ValidationException
Validates the given Object.- Specified by:
validate
in interfaceClassValidator
- Specified by:
validate
in interfaceTypeValidator
- Overrides:
validate
in classValidator
- Parameters:
object
- the Object that contains the field to validatecontext
- the ValidationContext- Throws:
ValidationException
- if validation fails
-
-