Package org.exolab.castor.xml.handlers
Class CollectionFieldHandler
java.lang.Object
org.exolab.castor.mapping.loader.FieldHandlerFriend
org.exolab.castor.mapping.ExtendedFieldHandler
org.exolab.castor.mapping.AbstractFieldHandler
org.exolab.castor.xml.XMLFieldHandler
org.exolab.castor.xml.handlers.CollectionFieldHandler
- All Implemented Interfaces:
ConfigurableFieldHandler
,FieldHandler
A FieldHandler for the XML Schema Collection type.
TODO : support all kind of XSList.
- Version:
- $Revision: 6671 $ $Date: 2003-03-03 00:05:44 -0700 (Mon, 03 Mar 2003) $
- Author:
- Arnaud Blandin
-
Field Summary
Fields inherited from class org.exolab.castor.mapping.AbstractFieldHandler
_properties
-
Constructor Summary
ConstructorsConstructorDescriptionCollectionFieldHandler
(FieldHandler fieldHandler) Creates a new CollectionFieldHandler using the given FieldHandler for delegation.CollectionFieldHandler
(FieldHandler fieldHandler, TypeValidator validator) Creates a new CollectionFieldHandler using the given FieldHandler for delegation and the given type validator for validation. -
Method Summary
Modifier and TypeMethodDescriptionvoid
checkValidity
(Object object) Checks the field validity.boolean
Returns true if the given object is an XMLFieldHandler that is equivalent to the delegated handler.Gets the value of the field associated with this descriptor.newInstance
(Object parent) Creates a new instance of the object described by this field.void
resetValue
(Object target) Sets the value of the field to a default value.void
Sets the value of the field associated with this descriptor.Methods inherited from class org.exolab.castor.xml.XMLFieldHandler
newInstance
Methods inherited from class org.exolab.castor.mapping.AbstractFieldHandler
getFieldDescriptor, hasValue, setConfiguration, setFieldDescriptor
-
Constructor Details
-
CollectionFieldHandler
Creates a new CollectionFieldHandler using the given FieldHandler for delegation.- Parameters:
fieldHandler
- the fieldHandler for delegation.
-
CollectionFieldHandler
Creates a new CollectionFieldHandler using the given FieldHandler for delegation and the given type validator for validation.- Parameters:
fieldHandler
- the fieldHandler for delegation.validator
- Type validator to use to validate an instance of this type.
-
-
Method Details
-
setValue
Sets the value of the field associated with this descriptor. If paased a String, then String is tokenized and each token is added as an individual instance to the collection.- Specified by:
setValue
in interfaceFieldHandler
- Overrides:
setValue
in classXMLFieldHandler
- Parameters:
target
- the object in which to set the valuevalue
- the value of the field- Throws:
IllegalStateException
- if any value provided fails validation.
-
getValue
Gets the value of the field associated with this descriptor. If the value is an array, it returns a string 'representing' this array- Specified by:
getValue
in interfaceFieldHandler
- Overrides:
getValue
in classXMLFieldHandler
- Parameters:
target
- the object from which to get the value- Returns:
- the value of the field associated with this descriptor.
- Throws:
IllegalStateException
- if any value provided fails validation.
-
resetValue
Sets the value of the field to a default value.- Specified by:
resetValue
in interfaceFieldHandler
- Overrides:
resetValue
in classXMLFieldHandler
- Parameters:
target
- The object to reset- Throws:
IllegalStateException
- if the Java object has changed and is no longer supported by this handler or the handler is not compatible with the Java object
-
checkValidity
Checks the field validity. Returns successfully if the field can be stored, is valid, etc, throws an exception otherwise.- Specified by:
checkValidity
in interfaceFieldHandler
- Overrides:
checkValidity
in classExtendedFieldHandler
- Parameters:
object
- The object- Throws:
ValidityException
- The field is invalid, is required and null, or any other validity violationIllegalStateException
- The Java object has changed and is no longer supported by this handler, or the handler is not compatiable with the Java object
-
newInstance
Creates a new instance of the object described by this field.- Specified by:
newInstance
in interfaceFieldHandler
- Overrides:
newInstance
in classXMLFieldHandler
- Parameters:
parent
- The object for which the field is created- Returns:
- A new instance of the field's value
- Throws:
IllegalStateException
- This field is a simple type and cannot be instantiated
-
equals
Returns true if the given object is an XMLFieldHandler that is equivalent to the delegated handler. An equivalent XMLFieldHandler is an XMLFieldHandler that is an instances of the same class.- Overrides:
equals
in classXMLFieldHandler
- Parameters:
obj
- The object to compare tothis
.- Returns:
- true if the given object is an XMLFieldHandler that is equivalent to this one.
-