|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.oddjob.arooa.reflect.IntrospectionHelper
Helper class that collects the methods a component or nested element holds to set attributes, create nested elements or hold PCDATA elements. The class is final as it has a private constructor.
Based on the original by Stefan Bodewig and Peter Reilly.
| Method Summary | |
void |
addText(java.lang.Object element,
java.lang.String text)
Adds PCDATA to an element, using the element's void addText(String) method, if it has one. |
java.lang.Object |
createElement(java.lang.String uri,
java.lang.Object parent,
java.lang.String elementName)
Creates a named nested element. |
void |
dump(java.io.PrintStream out)
Useful debug method to dump the internals of this class. |
java.lang.Class |
getAttributeType(java.lang.String attributeName)
Returns the type of a named attribute. |
java.lang.Class |
getElementType(java.lang.String elementName)
Returns the type of a named nested element. |
static IntrospectionHelper |
getHelper(java.lang.Class c)
Returns a helper for the given class, either from the cache or by creating a new instance. |
java.util.Enumeration |
getNestedElements()
Returns an enumeration of the names of the nested elements supported by the introspected class. |
static java.lang.String |
getPropertyName(java.lang.String methodName,
java.lang.String prefix)
Extracts the name of a property from a method name by subtracting a given prefix and converting into lower case. |
ArooaHandler |
provideHandler(java.lang.Object parent,
java.lang.String elementName,
ArooaContext context)
Provide a handler. |
static java.lang.Class |
selectBestMatchingClass(java.lang.Class match,
java.lang.Class[] set)
|
void |
storeComponent(java.lang.Object parent,
java.lang.Object child,
java.lang.String elementName)
Stores a named nested element using a storage method determined by the initial introspection. |
void |
storeConfiguredElement(java.lang.Object parent,
java.lang.Object child,
java.lang.String elementName)
Stores a named nested element using a storage method determined by the initial introspection. |
boolean |
supportsCharacters()
Returns whether or not the introspected class supports PCDATA. |
boolean |
supportsNestedElement(java.lang.String elementName)
Indicate if this element supports a nested element of the given name. |
void |
throwNotSupported(java.lang.Object parent,
java.lang.String elementName)
Utility method to throw a NotSupported exception |
static java.lang.Object |
valueFor(java.lang.Object from)
As with valueFor(Object, Class) but for the default type. |
static java.lang.Object |
valueFor(java.lang.Object from,
java.lang.Class required)
Get the value from the given type object if its a type wrapper, or the object itself. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static IntrospectionHelper getHelper(java.lang.Class c)
c - The class for which a helper is required. Must not be
null.
public void addText(java.lang.Object element,
java.lang.String text)
throws ArooaException
void addText(String) method, if it has one. If no
such method is present, a ArooaException is thrown if the
given text contains non-whitespace.
element - The element to add the text to.
Must not be null.text - The text to add.
Must not be null.
ArooaException - if non-whitespace text is provided and no
method is available to handle it, or if
the handling method fails.
public void throwNotSupported(java.lang.Object parent,
java.lang.String elementName)
parent - the object which doesn't support a requested elementelementName - the name of the Element which is trying to be created.
public java.lang.Object createElement(java.lang.String uri,
java.lang.Object parent,
java.lang.String elementName)
throws ArooaException
uri - Namespace uri.parent - Parent object used to create the instance.
Must not be null.elementName - Name of the element to create an instance of.
Must not be null.
ArooaException - if no method is available to create the
element instance, or if the creating method
fails.public boolean supportsNestedElement(java.lang.String elementName)
elementName - the name of the nested element being checked
public void storeConfiguredElement(java.lang.Object parent,
java.lang.Object child,
java.lang.String elementName)
throws ArooaException
parent - Parent instance to store the child in.
Must not be null.child - Child instance to store in the parent.
Should not be null.elementName - Name of the child element to store.
May be null, in which case
this method returns immediately.
ArooaException - if the storage method fails.
public ArooaHandler provideHandler(java.lang.Object parent,
java.lang.String elementName,
ArooaContext context)
throws ArooaException
parent - Parent instance.
Must not be null.elementName - Name of the child the handler is for.
May not be null.
ArooaException - if the storage method fails.
public void storeComponent(java.lang.Object parent,
java.lang.Object child,
java.lang.String elementName)
throws ArooaException
parent - Parent instance to store the child in.
Must not be null.child - Child instance to store in the parent.
Should not be null.elementName - Name of the child element to store.
May be null, in which case
this method returns immediately.
ArooaException - if the storage method fails.
public java.lang.Class getElementType(java.lang.String elementName)
throws ArooaException
elementName - The name of the element to find the type of. Must not be
null.
null.
ArooaException - if the introspected class does not support the named
nested element.
public java.lang.Class getAttributeType(java.lang.String attributeName)
throws ArooaException
attributeName - The name of the attribute to find the type of.
Must not be null.
null.
ArooaException - if the introspected class does not
support the named attribute.public boolean supportsCharacters()
public java.util.Enumeration getNestedElements()
public static java.lang.String getPropertyName(java.lang.String methodName,
java.lang.String prefix)
methodName - The name of the method in question.
Must not be null.prefix - The prefix to remove.
Must not be null.
public static java.lang.Object valueFor(java.lang.Object from,
java.lang.Class required)
throws java.lang.ClassCastException,
OddjobException
The returned object may not be of the required type but a defualt type
which a later org.appache.commons.beanutils.Converter might be able
to use (Probably a Sring).
from - The object which might have a valueFor method.required - The required class.
OddjobException - If the given object
getValue() method can't be invoked.
java.lang.ClassCastException
public static java.lang.Object valueFor(java.lang.Object from)
throws java.lang.ClassCastException,
OddjobException
valueFor(Object, Class) but for the default type.
from - The object which might have a valueFor method.
OddjobException - If the given object
getValue() method can't be invoked.
java.lang.ClassCastExceptionpublic void dump(java.io.PrintStream out)
out - The stream to dump to.
public static java.lang.Class selectBestMatchingClass(java.lang.Class match,
java.lang.Class[] set)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||