java.lang.Object | |
↳ | org.apache.commons.betwixt.XMLIntrospector |
XMLIntrospector
an introspector of beans to create a
XMLBeanInfo instance.
By default, XMLBeanInfo
caching is switched on.
This means that the first time that a request is made for a XMLBeanInfo
for a particular class, the XMLBeanInfo
is cached.
Later requests for the same class will return the cached value.
Note :
This class makes use of the java.bean.Introspector
class, which contains a BeanInfoSearchPath. To make sure betwixt can
do his work correctly, this searchpath is completely ignored during
processing. The original values will be restored after processing finished
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
log |
This field is deprecated.
0.6 use the getLog() property instead
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Base constructor
| |||||||||||
Construct allows a custom configuration to be set on construction.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Assigns the given method as an adder method to the given descriptor.
| |||||||||||
This method is deprecated.
0.5 use
createXMLDescriptor(BeanProperty) .
| |||||||||||
Create a XML descriptor from a bean one.
| |||||||||||
Add any addPropety(PropertyType) methods as Updaters
which are often used for 1-N relationships in beans.
| |||||||||||
Add any addPropety(PropertyType) methods as Updaters
which are often used for 1-N relationships in beans.
| |||||||||||
This method is deprecated.
0.5 use flushable registry instead
| |||||||||||
This method is deprecated.
0.6 getConfiguration().getAttributeNameMapper
| |||||||||||
This method is deprecated.
0.6 use getConfiguration().getClassNormalizer
| |||||||||||
Gets the configuration to be used for introspection.
| |||||||||||
This method is deprecated.
0.6 use getConfiguration().getElementNameMapper
| |||||||||||
Gets the current logging implementation. | |||||||||||
This method is deprecated.
0.5 getNameMapper is split up in
getElementNameMapper() and getAttributeNameMapper()
| |||||||||||
This method is deprecated.
0.6 use getConfiguration().getPluralStemmer
| |||||||||||
Gets the resolver for polymorphic references. | |||||||||||
Gets the current registry implementation. | |||||||||||
Create a standard
XMLBeanInfo by introspection. | |||||||||||
Create a standard
XMLBeanInfo by introspection
The actual introspection depends only on the BeanInfo
associated with the bean. | |||||||||||
Create a standard
XMLBeanInfo by introspection. | |||||||||||
Introspects the given | |||||||||||
Creates XMLBeanInfo by reading the DynaProperties of a DynaBean.
| |||||||||||
This method is deprecated.
0.6 use getConfiguration().isAttributesForPrimitives
| |||||||||||
This method is deprecated.
0.5 replaced by XMlBeanInfoRegistry
| |||||||||||
Is this class a loop?
| |||||||||||
Is this class a primitive?
| |||||||||||
This method is deprecated.
0.6 use getConfiguration().isWrapCollectionsInElement
| |||||||||||
Registers the class mappings specified in the multi-class document
given by the | |||||||||||
Registers the class mapping specified in the standard dot-betwixt file. | |||||||||||
This method is deprecated.
0.6 use getConfiguration().setAttributeNameMapper
| |||||||||||
This method is deprecated.
0.6 use getConfiguration().setAttributesForPrimitives
| |||||||||||
This method is deprecated.
0.5 replaced by XMlBeanInfoRegistry
| |||||||||||
This method is deprecated.
0.6 use getConfiguration().setClassNormalizer
| |||||||||||
Sets the configuration to be used for introspection.
| |||||||||||
This method is deprecated.
0.6 use getConfiguration().setElementNameMapper
| |||||||||||
Sets the current logging implementation. | |||||||||||
This method is deprecated.
0.5 setNameMapper is split up in
setElementNameMapper(NameMapper) and setAttributeNameMapper(NameMapper)
| |||||||||||
This method is deprecated.
0.6 use getConfiguration().setPluralStemmer
| |||||||||||
Sets the resolver for polymorphic references. | |||||||||||
Sets the | |||||||||||
This method is deprecated.
0.6 use getConfiguration().setUseBeanInfoSearchPath
| |||||||||||
This method is deprecated.
0.6 use getConfiguration().setWrapCollectionsInElement
| |||||||||||
This method is deprecated.
0.6 use getConfiguration().useBeanInfoSearchPath
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
This method is deprecated.
0.5 use
addProperties(BeanProperty[], List, List, List)
| |||||||||||
This method is deprecated.
0.5 this method does not support mixed content.
Use
addProperties(BeanInfo, List, List, List) instead.
| |||||||||||
Loop through properties and process each one
| |||||||||||
This method is deprecated.
0.5 use
addProperty(BeanProperty, List, List, List) instead
| |||||||||||
This method is deprecated.
0.5 this method does not support mixed content.
Use
addProperty(BeanInfo, PropertyDescriptor, List, List, List) instead.
| |||||||||||
Process a property.
| |||||||||||
This method is deprecated.
0.5 BeanInfo is no longer required.
Use
addProperty(PropertyDescriptor, List, List, List) instead.
| |||||||||||
This method is deprecated.
0.6 this method has been moved into IntrospectionConfiguration.
Those who need to vary this should subclass that class instead
| |||||||||||
This method is deprecated.
0.6 this method has been moved into IntrospectionConfiguration.
Those who need to vary this should subclass that class instead
| |||||||||||
Factory method to create XMLBeanInfo instances
| |||||||||||
Creates XMLBeanInfo for the given DynaClass.
| |||||||||||
Attempt to lookup the XML descriptor for the given class using the
classname + ".betwixt" using the same ClassLoader used to load the class
or return null if it could not be loaded
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Base constructor
Construct allows a custom configuration to be set on construction.
This allows IntrospectionConfiguration
subclasses
to be easily used.
configuration | IntrospectionConfiguration, not null |
---|
Assigns the given method as an adder method to the given descriptor.
twinParameterAdderMethod | adder Method , not null |
---|---|
matchingDescriptor | ElementDescriptor describing the element |
This method is deprecated.
0.5 use createXMLDescriptor(BeanProperty)
.
Create a XML descriptor from a bean one. Go through and work out whether it's a loop property, a primitive or a standard. The class property is ignored.
propertyDescriptor | create a NodeDescriptor for this property |
---|---|
useAttributesForPrimitives | write primitives as attributes (rather than elements) |
NodeDescriptor
for the propertyIntrospectionException | when bean introspection fails |
---|
Create a XML descriptor from a bean one. Go through and work out whether it's a loop property, a primitive or a standard. The class property is ignored.
beanProperty | the BeanProperty specifying the property |
---|
NodeDescriptor
for the propertyAdd any addPropety(PropertyType) methods as Updaters
which are often used for 1-N relationships in beans.
This method does not preserve null property names.
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.
TODO this probably needs refactoring. It probably belongs in the bean wrapper
(so that it'll work properly with dyna-beans) and so that the operations can
be optimized by caching. Multiple hash maps are created and getMethods is
called multiple times. This is relatively expensive and so it'd be better
to push into a proper class and cache.
rootDescriptor | add defaults to this descriptor |
---|---|
beanClass | the Class to which descriptor corresponds
|
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.
TODO this probably needs refactoring. It probably belongs in the bean wrapper
(so that it'll work properly with dyna-beans) and so that the operations can
be optimized by caching. Multiple hash maps are created and getMethods is
called multiple times. This is relatively expensive and so it'd be better
to push into a proper class and cache.
rootDescriptor | add defaults to this descriptor |
---|---|
beanClass | the Class to which descriptor corresponds |
This method is deprecated.
0.5 use flushable registry instead
Flush existing cached XMLBeanInfo
's.
This method is deprecated.
0.6 getConfiguration().getAttributeNameMapper
Gets the name mapping strategy used to convert bean names into attributes.
This method is deprecated.
0.6 use getConfiguration().getClassNormalizer
Gets the ClassNormalizer
strategy.
This is used to determine the Class to be introspected
(the normalized Class).
ClassNormalizer
used to determine the Class to be introspected
for a given Object.Gets the configuration to be used for introspection. The various introspection-time strategies and configuration variables have been consolidated as properties of this bean. This allows the configuration to be more easily shared.
This method is deprecated.
0.6 use getConfiguration().getElementNameMapper
Gets the name mapping strategy used to convert bean names into elements.
Gets the current logging implementation.
This method is deprecated.
0.5 getNameMapper is split up in
getElementNameMapper()
and getAttributeNameMapper()
Gets the name mapper strategy.
This method is deprecated.
0.6 use getConfiguration().getPluralStemmer
Get singular and plural matching strategy.
Gets the resolver for polymorphic references.
Though this is used only at bind time, it is typically tightly couple to the xml registry. It is therefore convenient to keep both references together.
Note: though the implementation is
set initially to the default registry,
this reference is not updated when setRegistry(XMLBeanInfoRegistry)
is called. Therefore, a call to setPolymorphicReferenceResolver(PolymorphicReferenceResolver)
with the instance may be necessary.
PolymorphicReferenceResolver
, not null
Gets the current registry implementation.
The registry is checked to see if it has an XMLBeanInfo
for a class
before introspecting.
After standard introspection is complete, the instance will be passed to the registry.
This allows finely grained control over the caching strategy. It also allows the standard introspection mechanism to be overridden on a per class basis.
Create a standard XMLBeanInfo
by introspection.
The actual introspection depends only on the BeanInfo
associated with the bean.
aClass | introspect this class |
---|
IntrospectionException | when the bean introspection fails |
---|
Create a standard XMLBeanInfo
by introspection
The actual introspection depends only on the BeanInfo
associated with the bean.
bean | introspect this bean |
---|
IntrospectionException | when the bean introspection fails |
---|
Create a standard XMLBeanInfo
by introspection.
The actual introspection depends only on the BeanInfo
associated with the bean.
beanInfo | the BeanInfo the xml-bean mapping is based on |
---|
IntrospectionException | when the bean introspection fails |
---|
Introspects the given Class
using the dot betwixt
document in the given InputSource
.
Note: that the given mapping will not
be registered by this method. Use register(Class, InputSource)
instead.
aClass | Class , not null |
---|---|
source | InputSource , not null |
XMLBeanInfo
describing the mapping.SAXException | when the input source cannot be parsed |
---|---|
IOException |
Creates XMLBeanInfo by reading the DynaProperties of a DynaBean. Customizing DynaBeans using betwixt is not supported.
dynaClass | the DynaBean to introspect |
---|
This method is deprecated.
0.6 use getConfiguration().isAttributesForPrimitives
Should attributes (or elements) be used for primitive types.
This method is deprecated.
0.5 replaced by XMlBeanInfoRegistry
Is XMLBeanInfo
caching enabled?
Is this class a loop?
type | the Class to test |
---|
Is this class a primitive?
type | the Class to test |
---|
This method is deprecated.
0.6 use getConfiguration().isWrapCollectionsInElement
Should collections be wrapped in an extra element?
Registers the class mappings specified in the multi-class document
given by the InputSource
.
Note: that this method will override any existing mapping for the speficied classes.
source | InputSource , not null |
---|
Class
array containing all mapped classesIntrospectionException | |
SAXException | |
IOException | |
IntrospectionException | |
SAXException |
Registers the class mapping specified in the standard dot-betwixt file. Subsequent introspections will use this registered mapping for the class.
Note: that this method will override any existing mapping for this class.
aClass | Class , not null |
---|---|
source | InputSource , not null |
SAXException | when the source cannot be parsed |
---|---|
IOException |
This method is deprecated.
0.6 use getConfiguration().setAttributeNameMapper
Sets the strategy used to convert bean type names into attribute names
nameMapper | the NameMapper to use for the convertion |
---|
This method is deprecated.
0.6 use getConfiguration().setAttributesForPrimitives
Set whether attributes (or elements) should be used for primitive types.
attributesForPrimitives | pass trus to map primitives to attributes, pass false to map primitives to elements |
---|
This method is deprecated.
0.5 replaced by XMlBeanInfoRegistry
Set whether XMLBeanInfo
caching should be enabled.
cachingEnabled | ignored |
---|
This method is deprecated.
0.6 use getConfiguration().setClassNormalizer
Sets the ClassNormalizer
strategy.
This is used to determine the Class to be introspected
(the normalized Class).
classNormalizer | the ClassNormalizer to be used to determine
the Class to be introspected for a given Object. |
---|
Sets the configuration to be used for introspection. The various introspection-time strategies and configuration variables have been consolidated as properties of this bean. This allows the configuration to be more easily shared.
configuration | IntrospectionConfiguration, not null |
---|
This method is deprecated.
0.6 use getConfiguration().setElementNameMapper
Sets the strategy used to convert bean type names into element names
nameMapper | the NameMapper to use for the conversion |
---|
Sets the current logging implementation.
log | the Log implementation to use for logging |
---|
This method is deprecated.
0.5 setNameMapper is split up in
setElementNameMapper(NameMapper)
and setAttributeNameMapper(NameMapper)
Sets the strategy used to convert bean type names into element names
nameMapper | the NameMapper strategy to be used |
---|
This method is deprecated.
0.6 use getConfiguration().setPluralStemmer
Sets the strategy used to detect matching singular and plural properties
pluralStemmer | the PluralStemmer used to match singular and plural |
---|
Sets the resolver for polymorphic references.
Though this is used only at bind time, it is typically tightly couple to the xml registry. It is therefore convenient to keep both references together.
Note: though the implementation is
set initially to the default registry,
this reference is not updated when setRegistry(XMLBeanInfoRegistry)
is called. Therefore, a call to setPolymorphicReferenceResolver(PolymorphicReferenceResolver)
with the instance may be necessary.
polymorphicReferenceResolver | The polymorphicReferenceResolver to set. |
---|
Sets the XMLBeanInfoRegistry
implementation.
The registry is checked to see if it has an XMLBeanInfo
for a class
before introspecting.
After standard introspection is complete, the instance will be passed to the registry.
This allows finely grained control over the caching strategy. It also allows the standard introspection mechanism to be overridden on a per class basis.
Note when using polymophic mapping with a custom
registry, a call to
setPolymorphicReferenceResolver(PolymorphicReferenceResolver)
may be necessary.
registry | the XMLBeanInfoRegistry to use |
---|
This method is deprecated.
0.6 use getConfiguration().setUseBeanInfoSearchPath
Specifies if you want to use the beanInfoSearchPath
This method is deprecated.
0.6 use getConfiguration().setWrapCollectionsInElement
Sets whether we should we wrap collections in an extra element.
wrapCollectionsInElement | pass true if collections should be wrapped in a parent element |
---|
This method is deprecated.
0.6 use getConfiguration().useBeanInfoSearchPath
Should the original java.reflect.Introspector
bean info search path be used?
By default it will be false.
This method is deprecated.
0.5 use addProperties(BeanProperty[], List, List, List)
Loop through properties and process each one
beanInfo | the BeanInfo whose properties will be processed |
---|---|
elements | ElementDescriptor list to which elements will be added |
attributes | AttributeDescriptor list to which attributes will be added |
contents | Descriptor list to which mixed content will be added |
IntrospectionException | if the bean introspection fails |
---|
This method is deprecated.
0.5 this method does not support mixed content.
Use addProperties(BeanInfo, List, List, List)
instead.
Loop through properties and process each one
beanInfo | the BeanInfo whose properties will be processed |
---|---|
elements | ElementDescriptor list to which elements will be added |
attributes | AttributeDescriptor list to which attributes will be added |
IntrospectionException | if the bean introspection fails |
---|
Loop through properties and process each one
beanProperties | the properties to be processed |
---|---|
elements | ElementDescriptor list to which elements will be added |
attributes | AttributeDescriptor list to which attributes will be added |
contents | Descriptor list to which mixed content will be added |
This method is deprecated.
0.5 use addProperty(BeanProperty, List, List, List)
instead
Process a property. Go through and work out whether it's a loop property, a primitive or a standard. The class property is ignored.
propertyDescriptor | the PropertyDescriptor to process |
---|---|
elements | ElementDescriptor list to which elements will be added |
attributes | AttributeDescriptor list to which attributes will be added |
contents | Descriptor list to which mixed content will be added |
IntrospectionException | if the bean introspection fails |
---|
This method is deprecated.
0.5 this method does not support mixed content.
Use addProperty(BeanInfo, PropertyDescriptor, List, List, List)
instead.
Process a property. Go through and work out whether it's a loop property, a primitive or a standard. The class property is ignored.
beanInfo | the BeanInfo whose property is being processed |
---|---|
propertyDescriptor | the PropertyDescriptor to process |
elements | ElementDescriptor list to which elements will be added |
attributes | AttributeDescriptor list to which attributes will be added |
IntrospectionException | if the bean introspection fails |
---|
Process a property. Go through and work out whether it's a loop property, a primitive or a standard. The class property is ignored.
beanProperty | the bean property to process |
---|---|
elements | ElementDescriptor list to which elements will be added |
attributes | AttributeDescriptor list to which attributes will be added |
contents | Descriptor list to which mixed content will be added |
This method is deprecated.
0.5 BeanInfo is no longer required.
Use addProperty(PropertyDescriptor, List, List, List)
instead.
Process a property. Go through and work out whether it's a loop property, a primitive or a standard. The class property is ignored.
beanInfo | the BeanInfo whose property is being processed |
---|---|
propertyDescriptor | the PropertyDescriptor to process |
elements | ElementDescriptor list to which elements will be added |
attributes | AttributeDescriptor list to which attributes will be added |
contents | Descriptor list to which mixed content will be added |
IntrospectionException | if the bean introspection fails |
---|
This method is deprecated.
0.6 this method has been moved into IntrospectionConfiguration.
Those who need to vary this should subclass that class instead
A Factory method to lazily create a strategy used to convert bean type names into element names.
This method is deprecated.
0.6 this method has been moved into IntrospectionConfiguration.
Those who need to vary this should subclass that class instead
A Factory method to lazily create a new strategy to detect matching singular and plural properties.
Factory method to create XMLBeanInfo instances
beanInfo | the BeanInfo from which the XMLBeanInfo will be created |
---|
Creates XMLBeanInfo for the given DynaClass.
dynaClass | the class describing a DynaBean |
---|
Attempt to lookup the XML descriptor for the given class using the classname + ".betwixt" using the same ClassLoader used to load the class or return null if it could not be loaded
aClass | digester .betwixt file for this class |
---|