| java.lang.Object org.apache.commons.betwixt.digester.XMLIntrospectorHelper
XMLIntrospectorHelper | public class XMLIntrospectorHelper (Code) | | 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 author: Martin van den Bemt |
Field Summary | |
protected static Log | log |
Method Summary | |
public static void | configureProperty(ElementDescriptor elementDescriptor, PropertyDescriptor propertyDescriptor) Configure an ElementDescriptor from a PropertyDescriptor . | public static void | configureProperty(ElementDescriptor elementDescriptor, PropertyDescriptor propertyDescriptor, String updateMethodName, Class beanClass) Configure an ElementDescriptor from a PropertyDescriptor .
A custom update method may be set.
Parameters: elementDescriptor - configure this ElementDescriptor Parameters: propertyDescriptor - configure from this PropertyDescriptor Parameters: updateMethodName - the name of the custom updater method to user. | public static void | configureProperty(AttributeDescriptor attributeDescriptor, PropertyDescriptor propertyDescriptor) | public static NodeDescriptor | createDescriptor(PropertyDescriptor propertyDescriptor, boolean useAttributesForPrimitives, XMLIntrospector introspector) Process a property. | public static void | defaultAddMethods(XMLIntrospector introspector, ElementDescriptor rootDescriptor, Class beanClass) 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. | protected static ElementDescriptor | findGetCollectionDescriptor(XMLIntrospector introspector, ElementDescriptor rootDescriptor, String propertyName) Attempts to find the element descriptor for the getter property that
typically matches a collection or array. | public static Log | getLog() | public static boolean | isLoopType(Class type) | public static boolean | isPrimitiveType(Class type) Is this a primitive type?
TODO: this method will probably be removed when primitive types
are subsumed into the simple type concept. | protected static void | makeElementDescriptorMap(ElementDescriptor rootDescriptor, Map map) | public static void | setLog(Log aLog) | protected static void | swapDescriptor(ElementDescriptor rootDescriptor, ElementDescriptor oldValue, ElementDescriptor newValue) Traverse the tree of element descriptors and find the oldValue and swap it with the newValue. |
log | protected static Log log(Code) | | Log used for logging (Doh!)
|
XMLIntrospectorHelper | public XMLIntrospectorHelper()(Code) | | Base constructor
|
configureProperty | public static void configureProperty(ElementDescriptor elementDescriptor, PropertyDescriptor propertyDescriptor)(Code) | | Configure an ElementDescriptor from a PropertyDescriptor .
This uses default element updater (the write method of the property).
Parameters: elementDescriptor - configure this ElementDescriptor Parameters: propertyDescriptor - configure from this PropertyDescriptor |
configureProperty | public static void configureProperty(ElementDescriptor elementDescriptor, PropertyDescriptor propertyDescriptor, String updateMethodName, Class beanClass)(Code) | | Configure an ElementDescriptor from a PropertyDescriptor .
A custom update method may be set.
Parameters: elementDescriptor - configure this ElementDescriptor Parameters: propertyDescriptor - configure from this PropertyDescriptor Parameters: updateMethodName - the name of the custom updater method to user. If null, then then Parameters: 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, PropertyDescriptor propertyDescriptor)(Code) | | Configure an AttributeDescriptor from a PropertyDescriptor
Parameters: attributeDescriptor - configure this AttributeDescriptor Parameters: propertyDescriptor - configure from this PropertyDescriptor |
createDescriptor | public static NodeDescriptor createDescriptor(PropertyDescriptor propertyDescriptor, boolean useAttributesForPrimitives, XMLIntrospector introspector) throws IntrospectionException(Code) | | 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 Parameters: useAttributesForPrimitives - write primitives as attributes (rather than elements) Parameters: introspector - use this XMLIntrospector a correctly configured NodeDescriptor for the property throws: IntrospectionException - when bean introspection failsXMLIntrospector.createDescriptor |
defaultAddMethods | public static void defaultAddMethods(XMLIntrospector introspector, ElementDescriptor rootDescriptor, Class beanClass)(Code) | | 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 Parameters: rootDescriptor - add defaults to this descriptor Parameters: beanClass - the Class to which descriptor corresponds |
findGetCollectionDescriptor | protected static ElementDescriptor findGetCollectionDescriptor(XMLIntrospector introspector, ElementDescriptor rootDescriptor, String propertyName)(Code) | | 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 Parameters: rootDescriptor - the ElementDescriptor whose child element will besearched for a match Parameters: propertyName - the name of the 'adder' method to match ElementDescriptor for the matching getter |
getLog | public static Log getLog()(Code) | | Gets the current logging implementation.
current log |
isPrimitiveType | public static boolean isPrimitiveType(Class type)(Code) | | 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? true for primitive types org.apache.commons.betwixt.strategy.TypeBindingStrategy |
makeElementDescriptorMap | protected static void makeElementDescriptorMap(ElementDescriptor rootDescriptor, Map map)(Code) | | 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 Parameters: map - the map to which the elements will be added |
setLog | public static void setLog(Log aLog)(Code) | | Sets the current logging implementation.
Parameters: aLog - use this Log |
swapDescriptor | protected static void swapDescriptor(ElementDescriptor rootDescriptor, ElementDescriptor oldValue, ElementDescriptor newValue)(Code) | | 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 Parameters: oldValue - replace this ElementDescriptor Parameters: newValue - replace with this ElementDescriptor |
|
|