org.progeeks.meta.xml
Class MetaObjectHandler

java.lang.Object
  extended by org.progeeks.util.xml.AbstractObjectHandler
      extended by org.progeeks.meta.xml.MetaObjectHandler
All Implemented Interfaces:
ObjectHandler
Direct Known Subclasses:
PreferencesMetaObjectHandler

public class MetaObjectHandler
extends AbstractObjectHandler

Object handler implementation to deal with converting XML to MetaObjects.

Version:
$Revision: 1.13 $
Author:
Paul Speed

Field Summary
static java.lang.String CONFIG_IMPORT_PACKAGE
           
 
Constructor Summary
MetaObjectHandler()
          Creates a new meta-object handler that will use a MapMetaKit to create new objects and the context class registry to resolve meta-classes.
MetaObjectHandler(MetaClassRegistry classRegistry, FormatRegistry formats, MetaKit metaKit)
          Creates a new meta-object handler that will use the specified meta-kit to create new objects and the specified class registry to resolve meta-classes
MetaObjectHandler(MetaKit metaKit)
          Creates a new meta-object handler that will use the specified meta-kit to create new objects and the context class registry to resolve meta-classes.
 
Method Summary
 void addClassPrefix(java.lang.String prefix)
          Adds a prefix to the class prefix list.
 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.
 java.util.List getClassPrefixes()
          Returns the current list of class prefixes.
 FormatRegistry getFormatRegistry()
          Returns the format registry associated with this handler.
 MetaClassRegistry getMetaClassRegistry()
          Returns the class registry associated with this handler.
 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  boolean ignoreAttribute(java.lang.String name, ObjectXmlReader reader)
          Returns true if the specified attribute should be ignored within the context of the specified reader.
 void importPackage(java.lang.String p)
          Adds a package + '.' to the list of class prefixes.
 void importPackages(java.util.List packages)
          Adds all packages specified to the list of class prefixes after appending a '.'.
protected  MetaClass resolveTagClass(java.lang.String tag)
          Attempts to find a meta-class that matches the specified tag.
 void setClassPrefixes(java.util.List prefixes)
          Sets the class prefix list.
 void setConfigurationProperty(java.lang.String property, java.lang.String value)
          Sends a configuration property to the handler implementation.
 void setFormatRegistry(FormatRegistry formats)
          Sets the format registry associated with this handler.
 void setMetaClassRegistry(MetaClassRegistry registry)
          Sets the class registry associated with this handler.
protected  void setObjectProperties(MetaObject obj, org.xml.sax.Attributes atts, ObjectXmlReader reader)
           
 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

MetaObjectHandler

public MetaObjectHandler()
Creates a new meta-object handler that will use a MapMetaKit to create new objects and the context class registry to resolve meta-classes.


MetaObjectHandler

public MetaObjectHandler(MetaKit metaKit)
Creates a new meta-object handler that will use the specified meta-kit to create new objects and the context class registry to resolve meta-classes.


MetaObjectHandler

public MetaObjectHandler(MetaClassRegistry classRegistry,
                         FormatRegistry formats,
                         MetaKit metaKit)
Creates a new meta-object handler that will use the specified meta-kit to create new objects and the specified class registry to resolve meta-classes

Method Detail

setMetaClassRegistry

public void setMetaClassRegistry(MetaClassRegistry registry)
Sets the class registry associated with this handler.


getMetaClassRegistry

public MetaClassRegistry getMetaClassRegistry()
Returns the class registry associated with this handler.


setFormatRegistry

public void setFormatRegistry(FormatRegistry formats)
Sets the format registry associated with this handler.


getFormatRegistry

public FormatRegistry getFormatRegistry()
Returns the format registry associated with this handler.


addClassPrefix

public void addClassPrefix(java.lang.String prefix)
Adds a prefix to the class prefix list. This is a set of prefixes that will be used when trying to resolve a meta-class name for a package name. The list is iterated in order and each prefix tried. For a java bean environment, the prefix should include the last period in the package name, ie: "java.util."


getClassPrefixes

public java.util.List getClassPrefixes()
Returns the current list of class prefixes.


setClassPrefixes

public void setClassPrefixes(java.util.List prefixes)
Sets the class prefix list.


importPackage

public void importPackage(java.lang.String p)
Adds a package + '.' to the list of class prefixes.


importPackages

public void importPackages(java.util.List packages)
Adds all packages specified to the list of class prefixes after appending a '.'.


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

resolveTagClass

protected MetaClass resolveTagClass(java.lang.String tag)
Attempts to find a meta-class that matches the specified tag.


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

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)
Returns true if the specified attribute should be ignored within the context of the specified reader. Default implementation simply defers to the reader's ignoreAttribute() method.


setObjectProperties

protected void setObjectProperties(MetaObject 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.