Project JXTA

net.jxta.document
Interface Element

All Known Subinterfaces:
StructuredDocument, StructuredTextDocument, TextElement, XMLDocument, XMLElement

public interface Element

An element represents a portion of a StructuredDocument. An element is identifiable by a key and may also optionally have a value. Each Element also maintains a collection of references to other elements, its children. Elmenents can be composed into arbitrary hierarchical structures forming complex data structures.

Element instances are always associated with a StructuredDocument. A StructuredDocument is a specialized form of Element with additional features that make it appropriate for acting as the root of a hierarchy of elements.

See Also:
Document, StructuredDocument, StructuredDocumentFactory, StructuredTextDocument, TextElement

Method Summary
 void appendChild(Element element)
          Add a child element to this element.
 Enumeration getChildren()
          Returns an enumeration of the immediate children of this element.
 Enumeration getChildren(Object key)
          Returns an enumeration of the immediate children of this element whose name match the specified key.
 Object getKey()
          Get the key associated with this Element.
 Element getParent()
          Get the parent element of this element.
 StructuredDocument getRoot()
          Get the root Element of the hierarchy this Element belongs to.
 Object getValue()
          Get the value (if any) associated with this Element.
 

Method Detail

getKey

public Object getKey()
Get the key associated with this Element.

Returns:
Object The key of this Element.

getValue

public Object getValue()
Get the value (if any) associated with this Element.

Returns:
Object The value of this element, if any, otherwise null.

getRoot

public StructuredDocument getRoot()
Get the root Element of the hierarchy this Element belongs to.

Returns:
StructuredDocument The root element of this element's hierarchy.

getParent

public Element getParent()
Get the parent element of this element. If this Element has not been inserted into the Document then null is returned. If this element is the root element of the Document then it returns itself. ie., this == this.getParent().

Returns:
Element parent of this element. If the element has no parent then null will be returned. If the element is the root Element of the hierarchy then it will return itself.

appendChild

public void appendChild(Element element)
Add a child element to this element. The child element must be from the document as the element it is to be added to.

Parameters:
element - the element to be added as a child

getChildren

public Enumeration getChildren()
Returns an enumeration of the immediate children of this element.

Returns:
Enumeration An enumeration containing all of the children of this element.

getChildren

public Enumeration getChildren(Object key)
Returns an enumeration of the immediate children of this element whose name match the specified key.

Parameters:
key - The key which will be matched against.
Returns:
Enumeration enumeration containing all of the children of this element.

JXTA J2SE