public class

XMLIntrospectorHelper

extends Object
java.lang.Object
   ↳ org.apache.commons.betwixt.digester.XMLIntrospectorHelper

This class is deprecated.
No replacement.

Class Overview

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.

Summary

Fields
protected static Log log Log used for logging (Doh!)
Public Constructors
XMLIntrospectorHelper()
Base constructor
Public Methods
static void configureProperty(AttributeDescriptor attributeDescriptor, PropertyDescriptor propertyDescriptor)
This method is deprecated. 0.6 moved into AttributeRule
static void configureProperty(ElementDescriptor elementDescriptor, PropertyDescriptor propertyDescriptor, String updateMethodName, Class beanClass)
This method is deprecated. 0.6 moved into ElementRule
static void configureProperty(ElementDescriptor elementDescriptor, PropertyDescriptor propertyDescriptor)
This method is deprecated. 0.6 unused
static NodeDescriptor createDescriptor(PropertyDescriptor propertyDescriptor, boolean useAttributesForPrimitives, XMLIntrospector introspector)
This method is deprecated. 0.5 this method has been replaced by createDescriptor(PropertyDescriptor, boolean)
static void defaultAddMethods(XMLIntrospector introspector, ElementDescriptor rootDescriptor, Class beanClass)
This method is deprecated. 0.6 use the method in XMLIntrospector instead
static Log getLog()

Gets the current logging implementation.

static boolean isLoopType(Class type)
This method is deprecated. 0.7 replaced by isLoopType(Class)
static boolean isPrimitiveType(Class type)
This method is deprecated. 0.6 replaced by TypeBindingStrategy
static void setLog(Log aLog)

Sets the current logging implementation.

Protected Methods
static ElementDescriptor findGetCollectionDescriptor(XMLIntrospector introspector, ElementDescriptor rootDescriptor, String propertyName)
This method is deprecated. 0.6 moved into XMLIntrospector
static void makeElementDescriptorMap(ElementDescriptor rootDescriptor, Map map)
This method is deprecated. 0.6 moved into XMLIntrospector
static void swapDescriptor(ElementDescriptor rootDescriptor, ElementDescriptor oldValue, ElementDescriptor newValue)
This method is deprecated. 0.6 now unused
[Expand]
Inherited Methods
From class java.lang.Object

Fields

protected static Log log

Log used for logging (Doh!)

Public Constructors

public XMLIntrospectorHelper ()

Base constructor

Public Methods

public static void configureProperty (AttributeDescriptor attributeDescriptor, PropertyDescriptor propertyDescriptor)

This method is deprecated.
0.6 moved into AttributeRule

Configure an AttributeDescriptor from a PropertyDescriptor

Parameters
attributeDescriptor configure this AttributeDescriptor
propertyDescriptor configure from this PropertyDescriptor

public static void configureProperty (ElementDescriptor elementDescriptor, PropertyDescriptor propertyDescriptor, String updateMethodName, Class beanClass)

This method is 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.

public static void configureProperty (ElementDescriptor elementDescriptor, PropertyDescriptor propertyDescriptor)

This method is 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

public static NodeDescriptor createDescriptor (PropertyDescriptor propertyDescriptor, boolean useAttributesForPrimitives, XMLIntrospector introspector)

This method is deprecated.
0.5 this method has been replaced by createDescriptor(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
IntrospectionException when bean introspection fails

public static void defaultAddMethods (XMLIntrospector introspector, ElementDescriptor rootDescriptor, Class beanClass)

This method is 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

public static Log getLog ()

Gets the current logging implementation.

Returns
  • current log

public static boolean isLoopType (Class type)

This method is deprecated.
0.7 replaced by 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

public static boolean isPrimitiveType (Class type)

This method is 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

public static void setLog (Log aLog)

Sets the current logging implementation.

Parameters
aLog use this Log

Protected Methods

protected static ElementDescriptor findGetCollectionDescriptor (XMLIntrospector introspector, ElementDescriptor rootDescriptor, String propertyName)

This method is 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

protected static void makeElementDescriptorMap (ElementDescriptor rootDescriptor, Map map)

This method is 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

protected static void swapDescriptor (ElementDescriptor rootDescriptor, ElementDescriptor oldValue, ElementDescriptor newValue)

This method is 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