org.progeeks.util.xml
Class MapObjectHandler

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

public class MapObjectHandler
extends BeanObjectHandler

ObjectHandler implementation that can treat a map as if it had a collection of Map.Entry objects.

The XML coding could then look like the following:

 <java.util.HashMap>
      <mapEntries>
         <map.Entry>
            <key><myFooBean /></key>
            <value><myBarBean /></value>
        </map.Entry>
        <map.Entry key="someKey" value="some value" />
     </mapEntries>
  </java.util.HashMap>
 

Version:
$Revision: 1.4 $
Author:
Matt Veitas

Nested Class Summary
static class MapObjectHandler.Entry
           
 
Field Summary
 
Fields inherited from class org.progeeks.util.xml.BeanObjectHandler
CONFIG_IMPORT_PACKAGE
 
Constructor Summary
MapObjectHandler()
           
 
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.
 java.lang.Class getPropertyClass(java.lang.Object obj, java.lang.String field, ObjectXmlReader reader)
          Returns the base type for the specified field.
 void setProperty(java.lang.Object obj, java.lang.String field, java.lang.Object value, ObjectXmlReader reader)
          Sets a property on the specified object.
 
Methods inherited from class org.progeeks.util.xml.BeanObjectHandler
getClass, getClass, getConstant, getInnerClass, getPackages, getProperty, getPropertyCollection, getTagClass, ignoreAttribute, importPackage, setConfigurationProperty, setObjectProperties, setPackages, setTextProperty
 
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

MapObjectHandler

public MapObjectHandler()
Method Detail

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
Overrides:
canHandle in class BeanObjectHandler

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
Overrides:
setProperty in class BeanObjectHandler

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
Overrides:
getPropertyClass in class BeanObjectHandler

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
Overrides:
createObject in class BeanObjectHandler


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