org.apache.commons.betwixt
Class XMLBeanInfo

java.lang.Object
  extended byorg.apache.commons.betwixt.XMLBeanInfo

public class XMLBeanInfo
extends Object

XMLBeanInfo represents the XML metadata information used to map a Java Bean cleanly to XML. This provides a default introspection mechansim, rather like BeanInfo which can be customized through some mechansim, either via Java code or XSLT for example.

ID and IDREF Attribute Names

These special attributes are defined in the xml specification. They are used by Betwixt to write bean graphs with cyclic references. In most cases, these will take the values 'id' and 'idref' respectively but these names can be varied in the DTD. Therefore, these names are specified by this class but default to the usual values.

Version:
$Revision: 1.6 $
Author:
James Strachan

Field Summary
private  Class beanClass
          the beans class that this XML info refers to
private  boolean cachedIDAttribute
          Have we already cached the idAttributeDescriptor?
private  ElementDescriptor elementDescriptor
          Descriptor for main element
private  AttributeDescriptor idAttributeDescriptor
          Cached ID attribute descriptor
private  String idAttributeName
          ID attribute name
private  String idrefAttributeName
          IDREF attribute name
 
Constructor Summary
XMLBeanInfo(Class beanClass)
          Base constructor
 
Method Summary
private  AttributeDescriptor findIDAttribute()
          ID attribute search implementation
 Class getBeanClass()
          Gets the beans class that this XML info refers to
 ElementDescriptor getElementDescriptor()
          Gets descriptor for bean represention
 AttributeDescriptor getIDAttribute()
          Search attributes for one matching ID attribute name
 String getIDAttributeName()
          Get name of ID attribute.
 String getIDREFAttributeName()
          Get IDREF attribute name This is used (for example) to deal with cyclic references.
 void setBeanClass(Class beanClass)
          Sets the beans class that this XML info refers to
 void setElementDescriptor(ElementDescriptor elementDescriptor)
          Sets descriptor for bean represention
 void setIDAttributeName(String idAttributeName)
          Set name of ID attribute This is used to write (for example) automatic ID attribute values.
 void setIDREFAttributeName(String idrefAttributeName)
          Set IDREF attribute name This is used (for example) to deal with cyclic references.
 String toString()
          Gets log-friendly string representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

elementDescriptor

private ElementDescriptor elementDescriptor
Descriptor for main element


beanClass

private Class beanClass
the beans class that this XML info refers to


idAttributeName

private String idAttributeName
ID attribute name


idrefAttributeName

private String idrefAttributeName
IDREF attribute name


cachedIDAttribute

private boolean cachedIDAttribute
Have we already cached the idAttributeDescriptor?


idAttributeDescriptor

private AttributeDescriptor idAttributeDescriptor
Cached ID attribute descriptor

Constructor Detail

XMLBeanInfo

public XMLBeanInfo(Class beanClass)
Base constructor

Parameters:
beanClass - for this Class
Method Detail

getElementDescriptor

public ElementDescriptor getElementDescriptor()
Gets descriptor for bean represention

Returns:
ElementDescriptor describing root element

setElementDescriptor

public void setElementDescriptor(ElementDescriptor elementDescriptor)
Sets descriptor for bean represention

Parameters:
elementDescriptor - descriptor for bean

getBeanClass

public Class getBeanClass()
Gets the beans class that this XML info refers to

Returns:
the beans class that this XML info refers to

setBeanClass

public void setBeanClass(Class beanClass)
Sets the beans class that this XML info refers to

Parameters:
beanClass - the class that this refers to

getIDAttribute

public AttributeDescriptor getIDAttribute()
Search attributes for one matching ID attribute name

Returns:
the xml ID attribute

findIDAttribute

private AttributeDescriptor findIDAttribute()
ID attribute search implementation

Returns:
the AttributeDescriptor for the ID attribute

getIDAttributeName

public String getIDAttributeName()

Get name of ID attribute. This is used to write (for example) automatic ID attribute values.

The default name is 'id'.

Returns:
name for the special ID attribute

setIDAttributeName

public void setIDAttributeName(String idAttributeName)
Set name of ID attribute This is used to write (for example) automatic ID attribute values.

The default name is 'id'.

Parameters:
idAttributeName - the attribute name for the special ID attribute

getIDREFAttributeName

public String getIDREFAttributeName()

Get IDREF attribute name This is used (for example) to deal with cyclic references.

The default name is 'idref'.

Returns:
name for the special IDREF attribute

setIDREFAttributeName

public void setIDREFAttributeName(String idrefAttributeName)
Set IDREF attribute name This is used (for example) to deal with cyclic references.

The default name is 'idref'.

Parameters:
idrefAttributeName - the attribute name for the special IDREF attribute

toString

public String toString()
Gets log-friendly string representation.

Returns:
something useful for logging