org.apache.commons.betwixt.digester
Class XMLIntrospectorHelper

java.lang.Object
  extended by org.apache.commons.betwixt.digester.XMLIntrospectorHelper

Deprecated.

public class XMLIntrospectorHelper
extends java.lang.Object

XMLIntrospectorHelper a helper class for common code shared between the digestor and introspector.

TODO this class will be deprecated soon need to move the isLoop and isPrimitiveType but probably need to think about whether they need replacing with something different.

Author:
James Strachan, Martin van den Bemt

Field Summary
protected static org.apache.commons.logging.Log log
          Deprecated. Log used for logging (Doh!)
 
Constructor Summary
XMLIntrospectorHelper()
          Deprecated. Base constructor
 
Method Summary
static void configureProperty(AttributeDescriptor attributeDescriptor, java.beans.PropertyDescriptor propertyDescriptor)
          Deprecated. 0.6 moved into AttributeRule
static void configureProperty(ElementDescriptor elementDescriptor, java.beans.PropertyDescriptor propertyDescriptor)
          Deprecated. 0.6 unused
static void configureProperty(ElementDescriptor elementDescriptor, java.beans.PropertyDescriptor propertyDescriptor, java.lang.String updateMethodName, java.lang.Class beanClass)
          Deprecated. 0.6 moved into ElementRule
static NodeDescriptor createDescriptor(java.beans.PropertyDescriptor propertyDescriptor, boolean useAttributesForPrimitives, XMLIntrospector introspector)
          Deprecated. 0.5 this method has been replaced by XMLIntrospector.createDescriptor(java.beans.PropertyDescriptor, boolean)
static void defaultAddMethods(XMLIntrospector introspector, ElementDescriptor rootDescriptor, java.lang.Class beanClass)
          Deprecated. 0.6 use the method in XMLIntrospector instead
protected static ElementDescriptor findGetCollectionDescriptor(XMLIntrospector introspector, ElementDescriptor rootDescriptor, java.lang.String propertyName)
          Deprecated. 0.6 moved into XMLIntrospector
static org.apache.commons.logging.Log getLog()
          Deprecated. Gets the current logging implementation.
static boolean isLoopType(java.lang.Class type)
          Deprecated. 0.7 replaced by IntrospectionConfiguration.isLoopType(Class)
static boolean isPrimitiveType(java.lang.Class type)
          Deprecated. 0.6 replaced by TypeBindingStrategy
protected static void makeElementDescriptorMap(ElementDescriptor rootDescriptor, java.util.Map map)
          Deprecated. 0.6 moved into XMLIntrospector
static void setLog(org.apache.commons.logging.Log aLog)
          Deprecated. Sets the current logging implementation.
protected static void swapDescriptor(ElementDescriptor rootDescriptor, ElementDescriptor oldValue, ElementDescriptor newValue)
          Deprecated. 0.6 now unused
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log
Deprecated. 
Log used for logging (Doh!)

Constructor Detail

XMLIntrospectorHelper

public XMLIntrospectorHelper()
Deprecated. 
Base constructor

Method Detail

getLog

public static org.apache.commons.logging.Log getLog()
Deprecated. 

Gets the current logging implementation.

Returns:
current log

setLog

public static void setLog(org.apache.commons.logging.Log aLog)
Deprecated. 

Sets the current logging implementation.

Parameters:
aLog - use this Log

createDescriptor

public static NodeDescriptor createDescriptor(java.beans.PropertyDescriptor propertyDescriptor,
                                              boolean useAttributesForPrimitives,
                                              XMLIntrospector introspector)
                                       throws java.beans.IntrospectionException
Deprecated. 0.5 this method has been replaced by XMLIntrospector.createDescriptor(java.beans.PropertyDescriptor, boolean)

Process a property. Go through and work out whether it's a loop property, a primitive or a standard. The class property is ignored.

Parameters:
propertyDescriptor - create a NodeDescriptor for this property
useAttributesForPrimitives - write primitives as attributes (rather than elements)
introspector - use this XMLIntrospector
Returns:
a correctly configured NodeDescriptor for the property
Throws:
java.beans.IntrospectionException - when bean introspection fails

configureProperty

public static void configureProperty(ElementDescriptor elementDescriptor,
                                     java.beans.PropertyDescriptor propertyDescriptor)
Deprecated. 0.6 unused

Configure an ElementDescriptor from a PropertyDescriptor. This uses default element updater (the write method of the property).

Parameters:
elementDescriptor - configure this ElementDescriptor
propertyDescriptor - configure from this PropertyDescriptor

configureProperty

public static void configureProperty(ElementDescriptor elementDescriptor,
                                     java.beans.PropertyDescriptor propertyDescriptor,
                                     java.lang.String updateMethodName,
                                     java.lang.Class beanClass)
Deprecated. 0.6 moved into ElementRule

Configure an ElementDescriptor from a PropertyDescriptor. A custom update method may be set.

Parameters:
elementDescriptor - configure this ElementDescriptor
propertyDescriptor - configure from this PropertyDescriptor
updateMethodName - the name of the custom updater method to user. If null, then then
beanClass - the Class from which the update method should be found. This may be null only when updateMethodName is also null.
Since:
0.5

configureProperty

public static void configureProperty(AttributeDescriptor attributeDescriptor,
                                     java.beans.PropertyDescriptor propertyDescriptor)
Deprecated. 0.6 moved into AttributeRule

Configure an AttributeDescriptor from a PropertyDescriptor

Parameters:
attributeDescriptor - configure this AttributeDescriptor
propertyDescriptor - configure from this PropertyDescriptor

defaultAddMethods

public static void defaultAddMethods(XMLIntrospector introspector,
                                     ElementDescriptor rootDescriptor,
                                     java.lang.Class beanClass)
Deprecated. 0.6 use the method in XMLIntrospector instead

Add any addPropety(PropertyType) methods as Updaters which are often used for 1-N relationships in beans.
The tricky part here is finding which ElementDescriptor corresponds to the method. e.g. a property 'items' might have an Element descriptor which the method addItem() should match to.
So the algorithm we'll use by default is to take the decapitalized name of the property being added and find the first ElementDescriptor that matches the property starting with the string. This should work for most use cases. e.g. addChild() would match the children property.

Parameters:
introspector - use this XMLIntrospector for introspection
rootDescriptor - add defaults to this descriptor
beanClass - the Class to which descriptor corresponds

isLoopType

public static boolean isLoopType(java.lang.Class type)
Deprecated. 0.7 replaced by IntrospectionConfiguration.isLoopType(Class)

Is this a loop type class?

Parameters:
type - is this Class a loop type?
Returns:
true if the type is a loop type, or if type is null

isPrimitiveType

public static boolean isPrimitiveType(java.lang.Class type)
Deprecated. 0.6 replaced by TypeBindingStrategy

Is this a primitive type? TODO: this method will probably be removed when primitive types are subsumed into the simple type concept. This needs moving into XMLIntrospector so that the list of simple type can be varied.

Parameters:
type - is this Class a primitive type?
Returns:
true for primitive types

findGetCollectionDescriptor

protected static ElementDescriptor findGetCollectionDescriptor(XMLIntrospector introspector,
                                                               ElementDescriptor rootDescriptor,
                                                               java.lang.String propertyName)
Deprecated. 0.6 moved into XMLIntrospector

Attempts to find the element descriptor for the getter property that typically matches a collection or array. The property name is used to match. e.g. if an addChild() method is detected the descriptor for the 'children' getter property should be returned.

Parameters:
introspector - use this XMLIntrospector
rootDescriptor - the ElementDescriptor whose child element will be searched for a match
propertyName - the name of the 'adder' method to match
Returns:
ElementDescriptor for the matching getter

makeElementDescriptorMap

protected static void makeElementDescriptorMap(ElementDescriptor rootDescriptor,
                                               java.util.Map map)
Deprecated. 0.6 moved into XMLIntrospector

Creates a map where the keys are the property names and the values are the ElementDescriptors

Parameters:
rootDescriptor - the values of the maps are the children of this ElementDescriptor index by their property names
map - the map to which the elements will be added

swapDescriptor

protected static void swapDescriptor(ElementDescriptor rootDescriptor,
                                     ElementDescriptor oldValue,
                                     ElementDescriptor newValue)
Deprecated. 0.6 now unused

Traverse the tree of element descriptors and find the oldValue and swap it with the newValue. This would be much easier to do if ElementDescriptor supported a parent relationship.

Parameters:
rootDescriptor - traverse child graph for this ElementDescriptor
oldValue - replace this ElementDescriptor
newValue - replace with this ElementDescriptor


Copyright 2002-2008 The Apache Software Foundation. All Rights Reserved.