JXTA

net.jxta.document
Interface Element<E extends Element<E>>

All Known Subinterfaces:
StructuredDocument<E>, StructuredTextDocument<T>, TextElement<T>, XMLDocument<X>, XMLElement<X>

public interface Element<E extends Element<E>>

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. Elements 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(E element)
          Add a child element to this element.
 Enumeration<E> getChildren()
          Returns an enumeration of the immediate children of this element.
 Enumeration<E> getChildren(Object key)
          Returns an enumeration of the immediate children of this element who match the specified key.
 Object getKey()
          Get the key associated with this Element.
 E getParent()
          Get the parent element of this element.
 StructuredDocument getRoot()
          Get the root document element of the hierarchy this element belongs to.
 Object getValue()
          Get the value (if any) associated with this Element.
 

Method Detail

getKey

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

Returns:
The key of this Element.

getValue

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

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

getRoot

StructuredDocument getRoot()
Get the root document element of the hierarchy this element belongs to.

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

getParent

E 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:
The 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

void appendChild(E 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. Elements are created using either StructuredDocument.createElement(Object) or StructuredDocument.createElement(Object, Object).

Parameters:
element - The element to be added as a child.

getChildren

Enumeration<E> getChildren()
Returns an enumeration of the immediate children of this element.

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

getChildren

Enumeration<E> getChildren(Object key)
Returns an enumeration of the immediate children of this element who match the specified key.

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

JXSE