com.openharbor.xmlj
Class Element

java.lang.Object
  extended bycom.openharbor.xmlj.Element
Direct Known Subclasses:
ObservableElement

public class Element
extends java.lang.Object

An XML element. This is a simple Document Object Model (DOM).

This model is less detailed than DOM4j or JDOM. For example, XML comments are not copied to Java objects, nor vice-versa. The positions of sub-elements within text are not represented; that is, XML text that is interspersed with elements is copied from XML as a single String (the value property). When copied to XML, the complete text comes first, followed by all the elements.


Nested Class Summary
protected static class Element.AttributeMap
          A Map representing the attributes of an Element.
protected static class Element.ElementList
          A List representing the subElements of an Element.
 
Field Summary
static java.lang.String EMPTY_VALUE
           
 
Constructor Summary
Element()
          It would be simpler Java to make attributes a member of attributeNanny and subElements a member of elementNanny.
Element(java.lang.String name)
           
Element(com.openharbor.beck.xml.XMLName name)
           
 
Method Summary
 java.util.Map getAttributes()
          Attributes of this Element.
 com.openharbor.beck.xml.XMLName getName()
           
 Element getParent()
           
 java.util.List getSubElements()
          Elements that are contained in this one.
 java.lang.String getValue()
           
protected  Element.AttributeMap newAttributeMap(java.util.Map real)
          Override this to customize the implementation of the attributes' Map.
protected  Element.ElementList newElementList()
          Override this to customize the implementation of the subElements' List.
 void setName(com.openharbor.beck.xml.XMLName name)
           
 void setValue(java.lang.String value)
          Set the text contained in this element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_VALUE

public static final java.lang.String EMPTY_VALUE
See Also:
Constant Field Values
Constructor Detail

Element

public Element()
It would be simpler Java to make attributes a member of attributeNanny and subElements a member of elementNanny. They are here, instead, to facilitate Object/Relational mapping using JDO, with the attributes and subElements fields mapped using one-to-many relationships. attributeNanny and elementNanny should not be persisted.


Element

public Element(com.openharbor.beck.xml.XMLName name)

Element

public Element(java.lang.String name)
Method Detail

getName

public com.openharbor.beck.xml.XMLName getName()

setName

public void setName(com.openharbor.beck.xml.XMLName name)

getValue

public java.lang.String getValue()
Returns:
the text contained in this element.

setValue

public void setValue(java.lang.String value)
Set the text contained in this element. setValue(null) sets the text to EMPTY_VALUE. This prevents the creation of Java structures that can't be represented in XML.


getParent

public Element getParent()

getAttributes

public java.util.Map getAttributes()
Attributes of this Element. This Map is limited to XML semantics. That is, every key is an XMLName and every value is a String. The implementation will convert other types to these. This prevents the creation of Java structures that can't be represented in XML.


getSubElements

public java.util.List getSubElements()
Elements that are contained in this one. An Element cannot be contained in two parent Elements; adding it to this List will also remove it from its previous parent. This prevents the creation of Java structures that can't be represented in XML.


newAttributeMap

protected Element.AttributeMap newAttributeMap(java.util.Map real)
Override this to customize the implementation of the attributes' Map.


newElementList

protected Element.ElementList newElementList()
Override this to customize the implementation of the subElements' List.