org.progeeks.util.xml
Class ClassRegistryHandler

java.lang.Object
  extended by org.progeeks.util.xml.AbstractObjectHandler
      extended by org.progeeks.util.xml.ClassRegistryHandler
All Implemented Interfaces:
ObjectHandler

public class ClassRegistryHandler
extends AbstractObjectHandler

ObjectHandler implementation that can read a class registry.

Version:
$Revision: 1.9 $
Author:
Paul Speed

Constructor Summary
ClassRegistryHandler()
           
 
Method Summary
 boolean canHandle(java.lang.String tag)
          Returns true if the tag is "classRegistry".
 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.
 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.
 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.
 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
 

Constructor Detail

ClassRegistryHandler

public ClassRegistryHandler()
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

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

canHandle

public boolean canHandle(java.lang.String tag)
Returns true if the tag is "classRegistry".

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 borrowed from the BeanObjectHandler.

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

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.