org.progeeks.util.xml
Class SystemPropertyObjectHandler

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

public class SystemPropertyObjectHandler
extends BeanObjectHandler

ObjectHandler implementation that can be used to import specific system properties into the XML object space. System properties are specified as:

      <property-string key="myValueKey" />
      <property-double key="myDoubleValueKey" />
      <property-integer key="myIntValueKey" />
  
...and so on.

Version:
$Revision: 1.19 $
Author:
Paul Speed

Nested Class Summary
 class SystemPropertyObjectHandler.ObjectPropertyHolder
          Version of the system property holder that allows configuration of the type to which strings will resolve.
 class SystemPropertyObjectHandler.SystemPropertyHolder
          Class for storing the intermediate object containing the information for determining the system property value.
 
Field Summary
 
Fields inherited from class org.progeeks.util.xml.BeanObjectHandler
CONFIG_IMPORT_PACKAGE
 
Constructor Summary
SystemPropertyObjectHandler()
          Constructor.
 
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.util.Properties getDefaultProperties()
          Returns the set of properties that will be used in place of any undefined system properties.
protected  java.lang.String getProperty(java.lang.String key)
          Internal method used to retrieve a property value.
protected  java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
          Internal method used to retrieve a property value.
 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 setDefaultProperties(java.util.Properties props)
          Sets the set of properties that will be used in place of any undefined system properties.
 
Methods inherited from class org.progeeks.util.xml.BeanObjectHandler
getClass, getClass, getConstant, getInnerClass, getPackages, getProperty, getPropertyClass, getPropertyCollection, getTagClass, ignoreAttribute, importPackage, setConfigurationProperty, setObjectProperties, setPackages, setProperty, setTextProperty
 
Methods inherited from class org.progeeks.util.xml.AbstractObjectHandler
setContainedText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SystemPropertyObjectHandler

public SystemPropertyObjectHandler()
Constructor.

Method Detail

setDefaultProperties

public void setDefaultProperties(java.util.Properties props)
Sets the set of properties that will be used in place of any undefined system properties.


getDefaultProperties

public java.util.Properties getDefaultProperties()
Returns the set of properties that will be used in place of any undefined system properties.


getProperty

protected java.lang.String getProperty(java.lang.String key)
Internal method used to retrieve a property value. Defers to the defaultProperties when the System.getProperty() returns null.


getProperty

protected java.lang.String getProperty(java.lang.String key,
                                       java.lang.String defaultValue)
Internal method used to retrieve a property value. Defers to the defaultProperties when the System.getProperty() returns null. Returns defaultValue if the property is undefined and a default value is set. If the property is undefined and no default value is set, an exception is generated.


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

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

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
Overrides:
resolveObject in class AbstractObjectHandler


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