org.progeeks.util.xml
Class AbstractObjectHandler

java.lang.Object
  extended by org.progeeks.util.xml.AbstractObjectHandler
All Implemented Interfaces:
ObjectHandler
Direct Known Subclasses:
BeanObjectHandler, ClassRegistryHandler, FormatRegistryHandler, JndiObjectHandler, JUnitHandler, MetaObjectHandler, StringObjectHandler

public abstract class AbstractObjectHandler
extends java.lang.Object
implements ObjectHandler

Abstract class that can be extended. Provides default implementations for some methods and helps future-proof code against interface changes.

Version:
$Revision: 1.5 $
Author:
Paul Speed

Constructor Summary
AbstractObjectHandler()
           
 
Method Summary
abstract  boolean canHandle(java.lang.String tag)
          Returns true if this handler applies to the specified object tag.
abstract  java.lang.Object createObject(java.lang.String tag, org.xml.sax.Attributes atts, ObjectXmlReader reader)
          Creates and returns an object based on the specified parameters.
abstract  java.lang.Object getProperty(java.lang.Object obj, java.lang.String field, ObjectXmlReader reader)
          Returns the current value of the specified property in the specified object.
abstract  java.lang.Class getPropertyClass(java.lang.Object obj, java.lang.String field, ObjectXmlReader reader)
          Returns the base type for the specified field.
abstract  java.util.Collection getPropertyCollection(java.lang.Object obj, java.lang.String field, ObjectXmlReader reader)
          Returns the a collection for the specified field that can be used to accumulate multiple object values.
 java.lang.Object resolveObject(java.lang.String tag, java.lang.Object obj, ObjectXmlReader reader)
          Converts a handler-specific internal representation of an object to a standard representation.
 void setConfigurationProperty(java.lang.String property, java.lang.String value)
          Sends a configuration property to the handler implementation.
 void setContainedText(java.lang.String tag, java.lang.Object obj, java.lang.String text, ObjectXmlReader reader)
          Called to apply any body text found during tag processing.
abstract  void setProperty(java.lang.Object obj, java.lang.String field, java.lang.Object value, ObjectXmlReader reader)
          Sets a property on the specified object.
abstract  void setTextProperty(java.lang.Object obj, java.lang.String field, java.lang.String value, ObjectXmlReader reader)
          Sets a text-value property on the specified object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractObjectHandler

public AbstractObjectHandler()
Method Detail

canHandle

public abstract boolean canHandle(java.lang.String tag)
Returns true if this handler applies to the specified object tag.

Specified by:
canHandle in interface ObjectHandler

setConfigurationProperty

public void setConfigurationProperty(java.lang.String property,
                                     java.lang.String value)
Sends a configuration property to the handler implementation. The implementation can use it or ignore it as it sees fit. Default implementation ignores all properties.

Specified by:
setConfigurationProperty in interface ObjectHandler

setProperty

public abstract void setProperty(java.lang.Object obj,
                                 java.lang.String field,
                                 java.lang.Object value,
                                 ObjectXmlReader reader)
Sets a property on the specified object.

Specified by:
setProperty in interface ObjectHandler

setTextProperty

public abstract void setTextProperty(java.lang.Object obj,
                                     java.lang.String field,
                                     java.lang.String value,
                                     ObjectXmlReader reader)
Sets a text-value property on the specified object. The handler may do some internal conversions to translate into an appropriate type.

Specified by:
setTextProperty in interface ObjectHandler

getPropertyClass

public abstract java.lang.Class getPropertyClass(java.lang.Object obj,
                                                 java.lang.String field,
                                                 ObjectXmlReader reader)
Returns the base type for the specified field. This is used to determine whether or not to accumulate field values in a collection.

Specified by:
getPropertyClass in interface ObjectHandler

getPropertyCollection

public abstract java.util.Collection getPropertyCollection(java.lang.Object obj,
                                                           java.lang.String field,
                                                           ObjectXmlReader reader)
Returns the a collection for the specified field that can be used to accumulate multiple object values. This is used when the XML field declaration specifies the progressive attribute.

Specified by:
getPropertyCollection in interface ObjectHandler

getProperty

public abstract java.lang.Object getProperty(java.lang.Object obj,
                                             java.lang.String field,
                                             ObjectXmlReader reader)
Returns the current value of the specified property in the specified object. This is used by the xml.existingValue directive and may eventually replace getPropertyCollection() as well.

Specified by:
getProperty in interface ObjectHandler

createObject

public abstract java.lang.Object createObject(java.lang.String tag,
                                              org.xml.sax.Attributes atts,
                                              ObjectXmlReader reader)
Creates and returns an object based on the specified parameters.

Specified by:
createObject in interface ObjectHandler

setContainedText

public void setContainedText(java.lang.String tag,
                             java.lang.Object obj,
                             java.lang.String text,
                             ObjectXmlReader reader)
Called to apply any body text found during tag processing.

Specified by:
setContainedText in interface ObjectHandler

resolveObject

public java.lang.Object resolveObject(java.lang.String tag,
                                      java.lang.Object obj,
                                      ObjectXmlReader reader)
Converts a handler-specific internal representation of an object to a standard representation. This is an implementation specific thing since some handlers will collect attributes/properties in an intermediate object. When the end of the tag is reached, the ObjectXmlReader will call this method to perform and necessary translations. Handlers that don't require resolution should just return the passed object. Default implementation returns obj.

Specified by:
resolveObject in interface ObjectHandler


Copyright © 2002-2003 Paul Speed. All Rights Reserved.