org.exolab.castor.xml.handlers
Class CollectionFieldHandler

java.lang.Object
  extended by org.exolab.castor.mapping.loader.FieldHandlerFriend
      extended by org.exolab.castor.mapping.ExtendedFieldHandler
          extended by org.exolab.castor.mapping.AbstractFieldHandler
              extended by org.exolab.castor.xml.XMLFieldHandler
                  extended by org.exolab.castor.xml.handlers.CollectionFieldHandler
All Implemented Interfaces:
ConfigurableFieldHandler, FieldHandler

public class CollectionFieldHandler
extends XMLFieldHandler

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
CollectionFieldHandler(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
 void checkValidity(java.lang.Object object)
          Checks the field validity.
 boolean equals(java.lang.Object obj)
          Returns true if the given object is an XMLFieldHandler that is equivalent to the delegated handler.
 java.lang.Object getValue(java.lang.Object target)
          Gets the value of the field associated with this descriptor.
 java.lang.Object newInstance(java.lang.Object parent)
          Creates a new instance of the object described by this field.
 void resetValue(java.lang.Object target)
          Sets the value of the field to a default value.
 void setValue(java.lang.Object target, java.lang.Object value)
          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
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CollectionFieldHandler

public CollectionFieldHandler(FieldHandler fieldHandler)
Creates a new CollectionFieldHandler using the given FieldHandler for delegation.

Parameters:
fieldHandler - the fieldHandler for delegation.

CollectionFieldHandler

public CollectionFieldHandler(FieldHandler fieldHandler,
                              TypeValidator validator)
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 Detail

setValue

public void setValue(java.lang.Object target,
                     java.lang.Object value)
              throws java.lang.IllegalStateException
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 interface FieldHandler
Overrides:
setValue in class XMLFieldHandler
Parameters:
target - the object in which to set the value
value - the value of the field
Throws:
java.lang.IllegalStateException - if any value provided fails validation.

getValue

public java.lang.Object getValue(java.lang.Object target)
                          throws java.lang.IllegalStateException
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 interface FieldHandler
Overrides:
getValue in class XMLFieldHandler
Parameters:
target - the object from which to get the value
Returns:
the value of the field associated with this descriptor.
Throws:
java.lang.IllegalStateException - if any value provided fails validation.

resetValue

public void resetValue(java.lang.Object target)
                throws java.lang.IllegalStateException
Sets the value of the field to a default value.

Specified by:
resetValue in interface FieldHandler
Overrides:
resetValue in class XMLFieldHandler
Parameters:
target - The object to reset
Throws:
java.lang.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

public void checkValidity(java.lang.Object object)
                   throws ValidityException,
                          java.lang.IllegalStateException
Checks the field validity. Returns successfully if the field can be stored, is valid, etc, throws an exception otherwise.

Specified by:
checkValidity in interface FieldHandler
Overrides:
checkValidity in class ExtendedFieldHandler
Parameters:
object - The object
Throws:
ValidityException - The field is invalid, is required and null, or any other validity violation
java.lang.IllegalStateException - The Java object has changed and is no longer supported by this handler, or the handler is not compatiable with the Java object

newInstance

public java.lang.Object newInstance(java.lang.Object parent)
                             throws java.lang.IllegalStateException
Creates a new instance of the object described by this field.

Specified by:
newInstance in interface FieldHandler
Overrides:
newInstance in class XMLFieldHandler
Parameters:
parent - The object for which the field is created
Returns:
A new instance of the field's value
Throws:
java.lang.IllegalStateException - This field is a simple type and cannot be instantiated

equals

public boolean equals(java.lang.Object obj)
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 class XMLFieldHandler
Parameters:
obj - The object to compare to this.
Returns:
true if the given object is an XMLFieldHandler that is equivalent to this one.


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