org.progeeks.util.xml
Class BeanObjectHandler

java.lang.Object
  extended by org.progeeks.util.xml.AbstractObjectHandler
      extended by org.progeeks.util.xml.BeanObjectHandler
All Implemented Interfaces:
ObjectHandler
Direct Known Subclasses:
ActionObjectHandler, AnnotationObjectHandler, BeanConfiguratorHandler, DefaultObjectHandler, FileSetHandler, MapObjectHandler, SystemPropertyObjectHandler, TypeRegistryHandler

public class BeanObjectHandler
extends AbstractObjectHandler

Object handler implementation to deal with converting XML to standard Java Beans.

Version:
$Revision: 1.25 $
Author:
Paul Speed

Field Summary
static java.lang.String CONFIG_IMPORT_PACKAGE
           
 
Constructor Summary
BeanObjectHandler()
           
 
Method Summary
 boolean canHandle(java.lang.String tag)
          Returns true if this handler applies to the specified object tag.
 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.
protected  java.lang.Class getClass(java.lang.String fullName)
          Returns the class for the specified fully qualified class name or null if the class does not exist.
protected  java.lang.Class getClass(java.lang.String pkg, java.lang.String name)
          Attempts to lookup a class with the given package and name.
protected  java.lang.Object getConstant(java.lang.String name, java.lang.Class type)
          Searches the specified type for a constant denoted by name.
protected  java.lang.Class getInnerClass(java.lang.String fullName)
          Returns the inner class for the specified fully qualified class name or null if the class does not exist.
 java.util.List getPackages()
          Returns the current list of packages.
 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.
 java.lang.Class getPropertyClass(java.lang.Object obj, java.lang.String field, ObjectXmlReader reader)
          Returns the base type for the specified field.
 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.
protected  java.lang.Class getTagClass(java.lang.String tag)
          Searches for a class that matches the specified tag name.
protected  boolean ignoreAttribute(java.lang.String name, ObjectXmlReader reader)
          A convenient place for subclasses to override attribute ignore behavior.
 void importPackage(java.lang.String packageName)
          Adds the specified package name to the list of imports that will be checked when a fully-qualified class name is not found.
 void setConfigurationProperty(java.lang.String property, java.lang.String value)
          Sends a configuration property to the handler implementation.
protected  void setObjectProperties(java.lang.Object obj, org.xml.sax.Attributes atts, ObjectXmlReader reader)
           
 void setPackages(java.util.List packages)
          Sets the list of packages to which this handler will refer when resolving class names.
 void setProperty(java.lang.Object obj, java.lang.String field, java.lang.Object value, ObjectXmlReader reader)
          Sets a property on the specified object.
 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 org.progeeks.util.xml.AbstractObjectHandler
resolveObject, setContainedText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIG_IMPORT_PACKAGE

public static final java.lang.String CONFIG_IMPORT_PACKAGE
See Also:
Constant Field Values
Constructor Detail

BeanObjectHandler

public BeanObjectHandler()
Method Detail

importPackage

public void importPackage(java.lang.String packageName)
Adds the specified package name to the list of imports that will be checked when a fully-qualified class name is not found.


setPackages

public void setPackages(java.util.List packages)
Sets the list of packages to which this handler will refer when resolving class names.


getPackages

public java.util.List getPackages()
Returns the current list of packages.


getClass

protected java.lang.Class getClass(java.lang.String fullName)
                            throws XmlException
Returns the class for the specified fully qualified class name or null if the class does not exist.

Throws:
XmlException

getInnerClass

protected java.lang.Class getInnerClass(java.lang.String fullName)
Returns the inner class for the specified fully qualified class name or null if the class does not exist. We have this version since we allow inner classes to be specified in the Java syntax. If the user specified the inner class with the $ based syntax then we're already done.


getClass

protected java.lang.Class getClass(java.lang.String pkg,
                                   java.lang.String name)
                            throws XmlException
Attempts to lookup a class with the given package and name. A check is also made for inner classes.

Throws:
XmlException

getTagClass

protected java.lang.Class getTagClass(java.lang.String tag)
                               throws XmlException
Searches for a class that matches the specified tag name.

Throws:
XmlException

getConstant

protected java.lang.Object getConstant(java.lang.String name,
                                       java.lang.Class type)
Searches the specified type for a constant denoted by name. If name contains a '.' the it is assumed to include its own class reference and the type parameter is ignored.


canHandle

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

Specified by:
canHandle in interface ObjectHandler
Specified by:
canHandle in class AbstractObjectHandler

setConfigurationProperty

public void setConfigurationProperty(java.lang.String property,
                                     java.lang.String value)
Sends a configuration property to the handler implementation. This implementation will use the "importPackage" property.

Specified by:
setConfigurationProperty in interface ObjectHandler
Overrides:
setConfigurationProperty in class AbstractObjectHandler

setProperty

public 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
Specified by:
setProperty in class AbstractObjectHandler

setTextProperty

public 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
Specified by:
setTextProperty in class AbstractObjectHandler

getPropertyClass

public 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
Specified by:
getPropertyClass in class AbstractObjectHandler

getPropertyCollection

public 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
Specified by:
getPropertyCollection in class AbstractObjectHandler

getProperty

public 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
Specified by:
getProperty in class AbstractObjectHandler

ignoreAttribute

protected boolean ignoreAttribute(java.lang.String name,
                                  ObjectXmlReader reader)
A convenient place for subclasses to override attribute ignore behavior.


setObjectProperties

protected void setObjectProperties(java.lang.Object obj,
                                   org.xml.sax.Attributes atts,
                                   ObjectXmlReader reader)

createObject

public 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
Specified by:
createObject in class AbstractObjectHandler


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