org.apache.commons.betwixt
Class ElementDescriptor

java.lang.Object
  extended by org.apache.commons.betwixt.NodeDescriptor
      extended by org.apache.commons.betwixt.ElementDescriptor

public class ElementDescriptor
extends NodeDescriptor

ElementDescriptor describes the XML elements to be created for a bean instance.

It contains AttributeDescriptor's for all it's attributes and ElementDescriptor's for it's child elements.

Version:
$Revision: 1.6.2.1 $
Author:
James Strachan, Martin van den Bemt

Field Summary
private  AttributeDescriptor[] attributeDescriptors
          Descriptors for attributes this element contains.
private  List attributeList
          The List used on construction.
private  Expression contextExpression
          the expression used to evaluate the new context of this node or null if the same context is to be used
private  ElementDescriptor[] elementDescriptors
          Descriptors for child elements.
private  List elementList
          The List used on construction.
private  boolean primitiveType
          Whether this element refers to a primitive type (or property of a parent object)
private  boolean wrapCollectionsInElement
          Whether this collection element can be used as a collection element.
 
Constructor Summary
ElementDescriptor()
          Constructs an ElementDescriptor that refers to a primitive type.
ElementDescriptor(boolean primitiveType)
          Base constructor.
ElementDescriptor(String localName)
          Creates a ElementDescriptor with no namespace URI or prefix.
ElementDescriptor(String localName, String qualifiedName, String uri)
          Creates a ElementDescriptor with namespace URI and qualified name
 
Method Summary
 void addAttributeDescriptor(AttributeDescriptor descriptor)
          Adds an attribute to the element this ElementDescriptor describes
 void addElementDescriptor(ElementDescriptor descriptor)
          Adds a descriptor for a child element.
 AttributeDescriptor[] getAttributeDescriptors()
          Returns the attribute descriptors for this element
protected  List getAttributeList()
          Lazily creates the mutable List.
 Expression getContextExpression()
          Returns the expression used to evaluate the new context of this element.
 ElementDescriptor[] getElementDescriptors()
          Returns descriptors for the child elements of the element this describes.
protected  List getElementList()
          Lazily creates the mutable List of child elements.
 boolean hasAttributes()
          Returns true if this element has AttributeDescriptors
 boolean hasChildren()
          Returns true if this element has child ElementDescriptors
 boolean isPrimitiveType()
          Returns true if this element refers to a primitive type property
 boolean isWrapCollectionsInElement()
          Returns true if collective bean properties should wrap the items in a parent element.
 void setAttributeDescriptors(AttributeDescriptor[] attributeDescriptors)
          Sets the AttributesDescriptors for this element.
 void setContextExpression(Expression contextExpression)
          Sets the expression used to evaluate the new context of this element
 void setElementDescriptors(ElementDescriptor[] elementDescriptors)
          Sets the descriptors for the child element of the element this describes.
 void setPrimitiveType(boolean primitiveType)
          Sets whether this element refers to a primitive type (or property of a parent object)
 void setWrapCollectionsInElement(boolean wrapCollectionsInElement)
          Sets whether Collection bean properties should wrap items in a parent element.
 String toString()
          Returns something useful for logging.
 
Methods inherited from class org.apache.commons.betwixt.NodeDescriptor
getLocalName, getPropertyName, getPropertyType, getQualifiedName, getSingularPropertyType, getTextExpression, getUpdater, getURI, setLocalName, setPropertyName, setPropertyType, setQualifiedName, setSingularPropertyType, setTextExpression, setUpdater, setURI
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

attributeDescriptors

private AttributeDescriptor[] attributeDescriptors
Descriptors for attributes this element contains. Constructed lazily on demand from a List


elementDescriptors

private ElementDescriptor[] elementDescriptors
Descriptors for child elements. Constructed lazily on demand from a List


attributeList

private List attributeList
The List used on construction. It will be GC'd after initilization and the array is lazily constructed


elementList

private List elementList
The List used on construction. It will be GC'd after initilization and the array is lazily constructed


contextExpression

private Expression contextExpression
the expression used to evaluate the new context of this node or null if the same context is to be used


primitiveType

private boolean primitiveType
Whether this element refers to a primitive type (or property of a parent object)


wrapCollectionsInElement

private boolean wrapCollectionsInElement
Whether this collection element can be used as a collection element. Defaults to true

Constructor Detail

ElementDescriptor

public ElementDescriptor()
Constructs an ElementDescriptor that refers to a primitive type.


ElementDescriptor

public ElementDescriptor(boolean primitiveType)
Base constructor.

Parameters:
primitiveType - if true, this element refers to a primitive type

ElementDescriptor

public ElementDescriptor(String localName)
Creates a ElementDescriptor with no namespace URI or prefix.

Parameters:
localName - the (xml) local name of this node. This will be used to set both qualified and local name for this name.

ElementDescriptor

public ElementDescriptor(String localName,
                         String qualifiedName,
                         String uri)
Creates a ElementDescriptor with namespace URI and qualified name

Parameters:
localName - the (xml) local name of this node
qualifiedName - the (xml) qualified name of this node
uri - the (xml) namespace prefix of this node
Method Detail

hasChildren

public boolean hasChildren()
Returns true if this element has child ElementDescriptors

Returns:
true if this element has child elements
See Also:
getElementDescriptors()

hasAttributes

public boolean hasAttributes()
Returns true if this element has AttributeDescriptors

Returns:
true if this element has attributes
See Also:
getAttributeDescriptors()

setWrapCollectionsInElement

public void setWrapCollectionsInElement(boolean wrapCollectionsInElement)
Sets whether Collection bean properties should wrap items in a parent element. In other words, should the mapping for bean properties which are Collections enclosed the item elements within a parent element. Normally only used when this describes a collection bean property.

Parameters:
wrapCollectionsInElement - true if the elements for the items in the collection should be contained in a parent element

isWrapCollectionsInElement

public boolean isWrapCollectionsInElement()
Returns true if collective bean properties should wrap the items in a parent element. In other words, should the mapping for bean properties which are Collections enclosed the item elements within a parent element. Normally only used when this describes a collection bean property.

Returns:
true if the elements for the items in the collection should be contained in a parent element

addAttributeDescriptor

public void addAttributeDescriptor(AttributeDescriptor descriptor)
Adds an attribute to the element this ElementDescriptor describes

Parameters:
descriptor - the AttributeDescriptor that will be added to the attributes associated with element this ElementDescriptor describes

getAttributeDescriptors

public AttributeDescriptor[] getAttributeDescriptors()
Returns the attribute descriptors for this element

Returns:
descriptors for the attributes of the element that this ElementDescriptor describes

setAttributeDescriptors

public void setAttributeDescriptors(AttributeDescriptor[] attributeDescriptors)
Sets the AttributesDescriptors for this element. This sets descriptors for the attributes of the element describe by the ElementDescriptor.

Parameters:
attributeDescriptors - the AttributeDescriptor describe the attributes of the element described by this ElementDescriptor

addElementDescriptor

public void addElementDescriptor(ElementDescriptor descriptor)
Adds a descriptor for a child element.

Parameters:
descriptor - the ElementDescriptor describing the child element to add

getElementDescriptors

public ElementDescriptor[] getElementDescriptors()
Returns descriptors for the child elements of the element this describes.

Returns:
the ElementDescriptor describing the child elements of the element that this ElementDescriptor describes

setElementDescriptors

public void setElementDescriptors(ElementDescriptor[] elementDescriptors)
Sets the descriptors for the child element of the element this describes.

Parameters:
elementDescriptors - the ElementDescriptors of the element that this describes

getContextExpression

public Expression getContextExpression()
Returns the expression used to evaluate the new context of this element.

Returns:
the expression used to evaluate the new context of this element

setContextExpression

public void setContextExpression(Expression contextExpression)
Sets the expression used to evaluate the new context of this element

Parameters:
contextExpression - the expression used to evaluate the new context of this element

isPrimitiveType

public boolean isPrimitiveType()
Returns true if this element refers to a primitive type property

Returns:
whether this element refers to a primitive type (or property of a parent object)

setPrimitiveType

public void setPrimitiveType(boolean primitiveType)
Sets whether this element refers to a primitive type (or property of a parent object)

Parameters:
primitiveType - true if this element refers to a primitive type

getAttributeList

protected List getAttributeList()
Lazily creates the mutable List. This nullifies the attributeDescriptors array so that as items are added to the list the Array is ignored until it is explicitly asked for.

Returns:
list of AttributeDescriptors's describing the attributes of the element that this ElementDescriptor describes

getElementList

protected List getElementList()
Lazily creates the mutable List of child elements. This nullifies the elementDescriptors array so that as items are added to the list the Array is ignored until it is explicitly asked for.

Returns:
list of ElementDescriptor's describe the child elements of the element that this ElementDescriptor describes

toString

public String toString()
Returns something useful for logging.

Overrides:
toString in class Object
Returns:
a string useful for logging