Main Page | Class Hierarchy | Class List | Class Members

org::jdom::Element Class Reference

Inheritance diagram for org::jdom::Element:

org::jdom::Content org::jdom::Parent List of all members.

Public Member Functions

 Element (String name, Namespace namespace)
 Element (String name)
 Element (String name, String uri)
 Element (String name, String prefix, String uri)
String getName ()
Element setName (String name)
Namespace getNamespace ()
Element setNamespace (Namespace namespace)
String getNamespacePrefix ()
String getNamespaceURI ()
Namespace getNamespace (String prefix)
String getQualifiedName ()
void addNamespaceDeclaration (Namespace additional)
void removeNamespaceDeclaration (Namespace additionalNamespace)
List getAdditionalNamespaces ()
String getValue ()
boolean isRootElement ()
int getContentSize ()
int indexOf (Content child)
String getText ()
String getTextTrim ()
String getTextNormalize ()
String getChildText (String name)
String getChildTextTrim (String name)
String getChildTextNormalize (String name)
String getChildText (String name, Namespace ns)
String getChildTextTrim (String name, Namespace ns)
String getChildTextNormalize (String name, Namespace ns)
Element setText (String text)
List getContent ()
List getContent (Filter filter)
List removeContent ()
List removeContent (Filter filter)
Element setContent (Collection newContent)
Element setContent (int index, Content child)
Parent setContent (int index, Collection collection)
Element addContent (String str)
Element addContent (Content child)
Element addContent (Collection collection)
Element addContent (int index, Content child)
Element addContent (int index, Collection c)
List cloneContent ()
Content getContent (int index)
boolean removeContent (Content child)
Content removeContent (int index)
Element setContent (Content child)
boolean isAncestor (Element element)
List getAttributes ()
Attribute getAttribute (String name)
Attribute getAttribute (String name, Namespace ns)
String getAttributeValue (String name)
String getAttributeValue (String name, String def)
String getAttributeValue (String name, Namespace ns)
String getAttributeValue (String name, Namespace ns, String def)
Element setAttributes (List newAttributes)
Element setAttribute (String name, String value)
Element setAttribute (String name, String value, Namespace ns)
Element setAttribute (Attribute attribute)
boolean removeAttribute (String name)
boolean removeAttribute (String name, Namespace ns)
boolean removeAttribute (Attribute attribute)
String toString ()
Object clone ()
Iterator getDescendants ()
Iterator getDescendants (Filter filter)
List getChildren ()
List getChildren (String name)
List getChildren (String name, Namespace ns)
Element getChild (String name, Namespace ns)
Element getChild (String name)
boolean removeChild (String name)
boolean removeChild (String name, Namespace ns)
boolean removeChildren (String name)
boolean removeChildren (String name, Namespace ns)

Protected Member Functions

 Element ()

Protected Attributes

String name
transient List additionalNamespaces

Package Attributes

AttributeList attributes = new AttributeList(this)
ContentList content = new ContentList(this)

Detailed Description

An XML element. Methods allow the user to get and manipulate its child elements and content, directly access the element's textual content, manipulate its attributes, and manage namespaces.

Version:
Revision
1.152
,
Date
2004/09/03 06:35:39
Author:
Brett McLaughlin

Jason Hunter

Lucas Gonze

Kevin Regan

Dan Schaffer

Yusuf Goolamabbas

Kent C. Johnson

Jools Enticknap

Alex Rosen

Bradley S. Huffman


Constructor & Destructor Documentation

org::jdom::Element::Element  )  [inline, protected]
 

This protected constructor is provided in order to support an Element subclass that wants full control over variable initialization. It intentionally leaves all instance variables null, allowing a lightweight subclass implementation. The subclass is responsible for ensuring all the get and set methods on Element behave as documented.

When implementing an Element subclass which doesn't require full control over variable initialization, be aware that simply calling super() (or letting the compiler add the implicit super() call) will not initialize the instance variables which will cause many of the methods to throw a NullPointerException. Therefore, the constructor for these subclasses should call one of the public constructors so variable initialization is handled automatically.

org::jdom::Element::Element String  name,
Namespace  namespace
[inline]
 

Creates a new element with the supplied (local) name and namespace. If the provided namespace is null, the element will have no namespace.

Parameters:
name local name of the element
namespace namespace for the element
Exceptions:
IllegalNameException if the given name is illegal as an element name

org::jdom::Element::Element String  name  )  [inline]
 

Create a new element with the supplied (local) name and no namespace.

Parameters:
name local name of the element
Exceptions:
IllegalNameException if the given name is illegal as an element name.

org::jdom::Element::Element String  name,
String  uri
[inline]
 

Creates a new element with the supplied (local) name and a namespace given by a URI. The element will be put into the unprefixed (default) namespace.

Parameters:
name name of the element
uri namespace URI for the element
Exceptions:
IllegalNameException if the given name is illegal as an element name or the given URI is illegal as a namespace URI

org::jdom::Element::Element String  name,
String  prefix,
String  uri
[inline]
 

Creates a new element with the supplied (local) name and a namespace given by the supplied prefix and URI combination.

Parameters:
name local name of the element
prefix namespace prefix
uri namespace URI for the element
Exceptions:
IllegalNameException if the given name is illegal as an element name, the given prefix is illegal as a namespace prefix, or the given URI is illegal as a namespace URI


Member Function Documentation

Element org::jdom::Element::addContent int  index,
Collection  c
[inline]
 

Inserts the content in a collection into the content list at the given index. In event of an exception the original content will be unchanged and the objects in the supplied collection will be unaltered.

Parameters:
index location for adding the collection
c collection to insert
Returns:
the parent on which the method was called
Exceptions:
IndexOutOfBoundsException if index is negative or beyond the current number of children
IllegalAddException if any item in the collection already has a parent or is of an inappropriate type.

Element org::jdom::Element::addContent int  index,
Content  child
[inline]
 

Inserts the child into the content list at the given index.

Parameters:
index location for adding the collection
child child to insert
Returns:
the parent on which the method was called
Exceptions:
IndexOutOfBoundsException if index is negative or beyond the current number of children
IllegalAddException if the given child already has a parent.

Element org::jdom::Element::addContent Collection  collection  )  [inline]
 

Appends all children in the given collection to the end of the content list. In event of an exception during add the original content will be unchanged and the objects in the supplied collection will be unaltered.

Parameters:
collection collection to append
Returns:
the element on which the method was called
Exceptions:
IllegalAddException if any item in the collection already has a parent or is of an inappropriate type.

Element org::jdom::Element::addContent Content  child  )  [inline]
 

Appends the child to the end of the element's content list.

Parameters:
child child to append to end of content list
Returns:
the element on which the method was called
Exceptions:
IllegalAddException if the given child already has a parent.

Element org::jdom::Element::addContent String  str  )  [inline]
 

This adds text content to this element. It does not replace the existing content as does setText().

Parameters:
str String to add
Returns:
this element modified
Exceptions:
IllegalDataException if str contains an illegal character such as a vertical tab (as determined by org.jdom.Verifier#checkCharacterData)

void org::jdom::Element::addNamespaceDeclaration Namespace  additional  )  [inline]
 

Adds a namespace declarations to this element. This should not be used to add the declaration for this element itself; that should be assigned in the construction of the element. Instead, this is for adding namespace declarations on the element not relating directly to itself. It's used during output to for stylistic reasons move namespace declarations higher in the tree than they would have to be.

Parameters:
additional namespace to add
Exceptions:
IllegalAddException if the namespace prefix collides with another namespace prefix on the element

Object org::jdom::Element::clone  )  [inline]
 

This returns a deep clone of this element. The new element is detached from its parent, and getParent() on the clone will return null.

Returns:
the clone of this element

Reimplemented from org::jdom::Content.

List org::jdom::Element::cloneContent  )  [inline]
 

Returns a list containing detached clones of this parent's content list.

Returns:
list of cloned child content

Implements org::jdom::Parent.

List org::jdom::Element::getAdditionalNamespaces  )  [inline]
 

Returns a list of the additional namespace declarations on this element. This includes only additional namespace, not the namespace of the element itself, which can be obtained through getNamespace(). If there are no additional declarations, this returns an empty list. Note, the returned list is unmodifiable.

Returns:
a List of the additional namespace declarations

Attribute org::jdom::Element::getAttribute String  name,
Namespace  ns
[inline]
 

This returns the attribute for this element with the given name and within the given Namespace, or null if no such attribute exists.

Parameters:
name name of the attribute to return
ns Namespace to search within
Returns:
attribute for the element

Attribute org::jdom::Element::getAttribute String  name  )  [inline]
 

This returns the attribute for this element with the given name and within no namespace, or null if no such attribute exists.

Parameters:
name name of the attribute to return
Returns:
attribute for the element

List org::jdom::Element::getAttributes  )  [inline]
 

This returns the complete set of attributes for this element, as a List of Attribute objects in no particular order, or an empty list if there are none. The returned list is "live" and changes to it affect the element's actual attributes.

Returns:
attributes for the element

String org::jdom::Element::getAttributeValue String  name,
Namespace  ns,
String  def
[inline]
 

This returns the attribute value for the attribute with the given name and within the given Namespace, or the passed-in default if there is no such attribute.

Parameters:
name name of the attribute whose valud is to be returned
ns Namespace to search within
def a default value to return if the attribute does not exist
Returns:
the named attribute's value, or the default if no such attribute

String org::jdom::Element::getAttributeValue String  name,
Namespace  ns
[inline]
 

This returns the attribute value for the attribute with the given name and within the given Namespace, null if there is no such attribute, and the empty string if the attribute value is empty.

Parameters:
name name of the attribute whose valud is to be returned
ns Namespace to search within
Returns:
the named attribute's value, or null if no such attribute

String org::jdom::Element::getAttributeValue String  name,
String  def
[inline]
 

This returns the attribute value for the attribute with the given name and within no namespace, or the passed-in default if there is no such attribute.

Parameters:
name name of the attribute whose value to be returned
def a default value to return if the attribute does not exist
Returns:
the named attribute's value, or the default if no such attribute

String org::jdom::Element::getAttributeValue String  name  )  [inline]
 

This returns the attribute value for the attribute with the given name and within no namespace, null if there is no such attribute, and the empty string if the attribute value is empty.

Parameters:
name name of the attribute whose value to be returned
Returns:
the named attribute's value, or null if no such attribute

Element org::jdom::Element::getChild String  name  )  [inline]
 

This returns the first child element within this element with the given local name and belonging to no namespace. If no elements exist for the specified name and namespace, null is returned.

Parameters:
name local name of child element to match
Returns:
the first matching child element, or null if not found

Element org::jdom::Element::getChild String  name,
Namespace  ns
[inline]
 

This returns the first child element within this element with the given local name and belonging to the given namespace. If no elements exist for the specified name and namespace, null is returned.

Parameters:
name local name of child element to match
ns Namespace to search within
Returns:
the first matching child element, or null if not found

List org::jdom::Element::getChildren String  name,
Namespace  ns
[inline]
 

This returns a List of all the child elements nested directly (one level deep) within this element with the given local name and belonging to the given Namespace, returned as Element objects. If this target element has no nested elements with the given name in the given Namespace, an empty List is returned. The returned list is "live" in document order and changes to it affect the element's actual contents.

Please see the notes for getChildren for a code example.

Parameters:
name local name for the children to match
ns Namespace to search within
Returns:
all matching child elements

List org::jdom::Element::getChildren String  name  )  [inline]
 

This returns a List of all the child elements nested directly (one level deep) within this element with the given local name and belonging to no namespace, returned as Element objects. If this target element has no nested elements with the given name outside a namespace, an empty List is returned. The returned list is "live" in document order and changes to it affect the element's actual contents.

Please see the notes for getChildren for a code example.

Parameters:
name local name for the children to match
Returns:
all matching child elements

List org::jdom::Element::getChildren  )  [inline]
 

This returns a List of all the child elements nested directly (one level deep) within this element, as Element objects. If this target element has no nested elements, an empty List is returned. The returned list is "live" in document order and changes to it affect the element's actual contents.

Sequential traversal through the List is best done with a Iterator since the underlying implement of List.size() may not be the most efficient.

No recursion is performed, so elements nested two levels deep would have to be obtained with:

 
   Iterator itr = (currentElement.getChildren()).iterator();
   while(itr.hasNext()) {
     Element oneLevelDeep = (Element)itr.next();
     List twoLevelsDeep = oneLevelDeep.getChildren();
     // Do something with these children
   }
 
 

Returns:
list of child Element objects for this element

String org::jdom::Element::getChildText String  name,
Namespace  ns
[inline]
 

Returns the textual content of the named child element, or null if there's no such child.

Parameters:
name the name of the child
ns the namespace of the child
Returns:
text content for the named child, or null if no such child

String org::jdom::Element::getChildText String  name  )  [inline]
 

Returns the textual content of the named child element, or null if there's no such child. This method is a convenience because calling getChild().getText() can throw a NullPointerException.

Parameters:
name the name of the child
Returns:
text content for the named child, or null if no such child

String org::jdom::Element::getChildTextNormalize String  name,
Namespace  ns
[inline]
 

Returns the normalized textual content of the named child element, or null if there's no such child.

Parameters:
name the name of the child
ns the namespace of the child
Returns:
normalized text content for the named child, or null if no such child

String org::jdom::Element::getChildTextNormalize String  name  )  [inline]
 

Returns the normalized textual content of the named child element, or null if there's no such child. See getTextNormalize() for details of text normalizing.

Parameters:
name the name of the child
Returns:
normalized text content for the named child, or null if no such child

String org::jdom::Element::getChildTextTrim String  name,
Namespace  ns
[inline]
 

Returns the trimmed textual content of the named child element, or null if there's no such child.

Parameters:
name the name of the child
ns the namespace of the child
Returns:
trimmed text content for the named child, or null if no such child

String org::jdom::Element::getChildTextTrim String  name  )  [inline]
 

Returns the trimmed textual content of the named child element, or null if there's no such child. See getTextTrim() for details of text trimming.

Parameters:
name the name of the child
Returns:
trimmed text content for the named child, or null if no such child

Content org::jdom::Element::getContent int  index  )  [inline]
 

Returns the child at the given index.

Parameters:
index location of desired child
Returns:
child at the given index
Exceptions:
IndexOutOfBoundsException if index is negative or beyond the current number of children
IllegalStateException if parent is a Document and the root element is not set

Implements org::jdom::Parent.

List org::jdom::Element::getContent Filter  filter  )  [inline]
 

Return a filter view of this Element's content.

Sequential traversal through the List is best done with a Iterator since the underlying implement of List.size() may require walking the entire list.

Parameters:
filter Filter to apply
Returns:
List - filtered Element content

Implements org::jdom::Parent.

List org::jdom::Element::getContent  )  [inline]
 

This returns the full content of the element as a List which may contain objects of type Text, Element, Comment, ProcessingInstruction, CDATA, and EntityRef. The List returned is "live" in document order and modifications to it affect the element's actual contents. Whitespace content is returned in its entirety.

Sequential traversal through the List is best done with an Iterator since the underlying implement of List.size() may require walking the entire list.

Returns:
a List containing the mixed content of the element: may contain Text, Element, Comment, ProcessingInstruction, CDATA, and EntityRef objects.

Implements org::jdom::Parent.

int org::jdom::Element::getContentSize  )  [inline]
 

Returns the number of children in this parent's content list. Children may be any Content type.

Returns:
number of children

Implements org::jdom::Parent.

Iterator org::jdom::Element::getDescendants Filter  filter  )  [inline]
 

Returns an iterator that walks over all descendants in document order applying the Filter to return only elements that match the filter rule. With filters you can match only Elements, only Comments, Elements or Comments, only Elements with a given name and/or prefix, and so on.

Parameters:
filter filter to select which descendants to see
Returns:
an iterator to walk descendants within a filter

Implements org::jdom::Parent.

Iterator org::jdom::Element::getDescendants  )  [inline]
 

Returns an iterator that walks over all descendants in document order.

Returns:
an iterator to walk descendants

Implements org::jdom::Parent.

String org::jdom::Element::getName  )  [inline]
 

Returns the (local) name of the element (without any namespace prefix).

Returns:
local element name

Namespace org::jdom::Element::getNamespace String  prefix  )  [inline]
 

Returns the Namespace corresponding to the given prefix in scope for this element. This involves searching up the tree, so the results depend on the current location of the element. Returns null if there is no namespace in scope with the given prefix at this point in the document.

Parameters:
prefix namespace prefix to look up
Returns:
the Namespace for this prefix at this location, or null if none

Namespace org::jdom::Element::getNamespace  )  [inline]
 

Returns the element's Namespace.

Returns:
the element's namespace

String org::jdom::Element::getNamespacePrefix  )  [inline]
 

Returns the namespace prefix of the element or an empty string if none exists.

Returns:
the namespace prefix

String org::jdom::Element::getNamespaceURI  )  [inline]
 

Returns the namespace URI mapped to this element's prefix (or the in-scope default namespace URI if no prefix). If no mapping is found, an empty string is returned.

Returns:
the namespace URI for this element

String org::jdom::Element::getQualifiedName  )  [inline]
 

Returns the full name of the element, in the form [namespacePrefix]:[localName]. If the element does not have a namespace prefix, then the local name is returned.

Returns:
qualified name of the element (including namespace prefix)

String org::jdom::Element::getText  )  [inline]
 

Returns the textual content directly held under this element as a string. This includes all text within this single element, including whitespace and CDATA sections if they exist. It's essentially the concatenation of all Text and CDATA nodes returned by getContent. The call does not recurse into child elements. If no textual value exists for the element, an empty string is returned.

Returns:
text content for this element, or empty string if none

String org::jdom::Element::getTextNormalize  )  [inline]
 

Returns the textual content of this element with all surrounding whitespace removed and internal whitespace normalized to a single space. If no textual value exists for the element, or if only whitespace exists, the empty string is returned.

Returns:
normalized text content for this element, or empty string if none

String org::jdom::Element::getTextTrim  )  [inline]
 

Returns the textual content of this element with all surrounding whitespace removed. If no textual value exists for the element, or if only whitespace exists, the empty string is returned.

Returns:
trimmed text content for this element, or empty string if none

String org::jdom::Element::getValue  )  [inline, virtual]
 

Returns the XPath 1.0 string value of this element, which is the complete, ordered content of all text node descendants of this element (i.e. the text that's left after all references are resolved and all other markup is stripped out.)

Returns:
a concatentation of all text node descendants

Implements org::jdom::Content.

int org::jdom::Element::indexOf Content  child  )  [inline]
 

Returns the index of the supplied child in the content list, or -1 if not a child of this parent.

Parameters:
child child to search for
Returns:
index of child, or -1 if not found

Implements org::jdom::Parent.

boolean org::jdom::Element::isAncestor Element  element  )  [inline]
 

Determines if this element is the ancestor of another element.

Parameters:
element Element to check against
Returns:
true if this element is the ancestor of the supplied element

boolean org::jdom::Element::isRootElement  )  [inline]
 

Returns whether this element is a root element. This can be used in tandem with getParent to determine if an element has any "attachments" to a parent element or document.

Returns:
whether this is a root element

boolean org::jdom::Element::removeAttribute Attribute  attribute  )  [inline]
 

This removes the supplied Attribute should it exist.

Parameters:
attribute Reference to the attribute to be removed.
Returns:
whether the attribute was removed

boolean org::jdom::Element::removeAttribute String  name,
Namespace  ns
[inline]
 

This removes the attribute with the given name and within the given Namespace. If no such attribute exists, this method does nothing.

Parameters:
name name of attribute to remove
ns namespace URI of attribute to remove
Returns:
whether the attribute was removed

boolean org::jdom::Element::removeAttribute String  name  )  [inline]
 

This removes the attribute with the given name and within no namespace. If no such attribute exists, this method does nothing.

Parameters:
name name of attribute to remove
Returns:
whether the attribute was removed

boolean org::jdom::Element::removeChild String  name,
Namespace  ns
[inline]
 

This removes the first child element (one level deep) with the given local name and belonging to the given namespace. Returns true if a child was removed.

Parameters:
name the name of child element to remove
ns Namespace to search within
Returns:
whether deletion occurred

boolean org::jdom::Element::removeChild String  name  )  [inline]
 

This removes the first child element (one level deep) with the given local name and belonging to no namespace. Returns true if a child was removed.

Parameters:
name the name of child elements to remove
Returns:
whether deletion occurred

boolean org::jdom::Element::removeChildren String  name,
Namespace  ns
[inline]
 

This removes all child elements (one level deep) with the given local name and belonging to the given namespace. Returns true if any were removed.

Parameters:
name the name of child elements to remove
ns Namespace to search within
Returns:
whether deletion occurred

boolean org::jdom::Element::removeChildren String  name  )  [inline]
 

This removes all child elements (one level deep) with the given local name and belonging to no namespace. Returns true if any were removed.

Parameters:
name the name of child elements to remove
Returns:
whether deletion occurred

Content org::jdom::Element::removeContent int  index  )  [inline]
 

Removes and returns the child at the given index, or returns null if there's no such child.

Parameters:
index index of child to remove
Returns:
detached child at given index or null if no
Exceptions:
IndexOutOfBoundsException if index is negative or beyond the current number of children

Implements org::jdom::Parent.

boolean org::jdom::Element::removeContent Content  child  )  [inline]
 

Removes a single child node from the content list.

Parameters:
child child to remove
Returns:
whether the removal occurred

Implements org::jdom::Parent.

List org::jdom::Element::removeContent Filter  filter  )  [inline]
 

Remove all child content from this parent matching the supplied filter.

Parameters:
filter filter to select which content to remove
Returns:
list of the old children detached from this parent

Implements org::jdom::Parent.

List org::jdom::Element::removeContent  )  [inline]
 

Removes all child content from this parent.

Returns:
list of the old children detached from this parent

Implements org::jdom::Parent.

void org::jdom::Element::removeNamespaceDeclaration Namespace  additionalNamespace  )  [inline]
 

Removes an additional namespace declarations from this element. This should not be used to remove the declaration for this element itself; that should be handled in the construction of the element. Instead, this is for removing namespace declarations on the element not relating directly to itself. If the declaration is not present, this method does nothing.

Parameters:
additionalNamespace namespace to remove

Element org::jdom::Element::setAttribute Attribute  attribute  )  [inline]
 

This sets an attribute value for this element. Any existing attribute with the same name and namespace URI is removed.

Parameters:
attribute Attribute to set
Returns:
this element modified
Exceptions:
IllegalAddException if the attribute being added already has a parent or if the attribute namespace prefix collides with another namespace prefix on the element.

Element org::jdom::Element::setAttribute String  name,
String  value,
Namespace  ns
[inline]
 

This sets an attribute value for this element. Any existing attribute with the same name and namespace URI is removed.

Parameters:
name name of the attribute to set
value value of the attribute to set
ns namespace of the attribute to set
Returns:
this element modified
Exceptions:
IllegalNameException if the given name is illegal as an attribute name, or if the namespace is an unprefixed default namespace
IllegalDataException if the given attribute value is illegal character data (as determined by org.jdom.Verifier#checkCharacterData).
IllegalAddException if the attribute namespace prefix collides with another namespace prefix on the element.

Element org::jdom::Element::setAttribute String  name,
String  value
[inline]
 

This sets an attribute value for this element. Any existing attribute with the same name and namespace URI is removed.

Parameters:
name name of the attribute to set
value value of the attribute to set
Returns:
this element modified
Exceptions:
IllegalNameException if the given name is illegal as an attribute name.
IllegalDataException if the given attribute value is illegal character data (as determined by org.jdom.Verifier#checkCharacterData).

Element org::jdom::Element::setAttributes List  newAttributes  )  [inline]
 

This sets the attributes of the element. The supplied List should contain only objects of type Attribute.

When all objects in the supplied List are legal and before the new attributes are added, all old attributes will have their parentage set to null (no parent) and the old attribute list will be cleared. This has the effect that any active attribute list (previously obtained with a call to getAttributes) will also change to reflect the new attributes. In addition, all attributes in the supplied List will have their parentage set to this element, but the List itself will not be "live" and further removals and additions will have no effect on this elements attributes. If the user wants to continue working with a "live" attribute list, then a call to setAttributes should be followed by a call to getAttributes to obtain a "live" version of the attributes.

Passing a null or empty List clears the existing attributes.

In cases where the List contains duplicate attributes, only the last one will be retained. This has the same effect as calling setAttribute(Attribute) sequentially.

In event of an exception the original attributes will be unchanged and the attributes in the supplied attributes will be unaltered.

Parameters:
newAttributes List of attributes to set
Returns:
this element modified
Exceptions:
IllegalAddException if the List contains objects that are not instances of Attribute, or if any of the Attribute objects have conflicting namespace prefixes.

Element org::jdom::Element::setContent Content  child  )  [inline]
 

Set this element's content to be the supplied child.

If the supplied child is legal content for this parent and before it is added, all content in the current content list will be cleared and all current children will have their parentage set to null.

This has the effect that any active list (previously obtained with a call to one of the getContent methods will also change to reflect the new content. In addition, all content in the supplied collection will have their parentage set to this parent. If the user wants to continue working with a "live" list of this parent's child, then a call to setContent should be followed by a call to one of the getContent methods to obtain a "live" version of the children.

Passing a null child clears the existing content.

In event of an exception the original content will be unchanged and the supplied child will be unaltered.

Parameters:
child new content to replace existing content
Returns:
the parent on which the method was called
Exceptions:
IllegalAddException if the supplied child is already attached or not legal content for an Element

Parent org::jdom::Element::setContent int  index,
Collection  collection
[inline]
 

Replace the child at the given index whith the supplied collection.

In event of an exception the original content will be unchanged and the content in the supplied collection will be unaltered.

Parameters:
index - index of child to replace.
collection - collection of content to add.
Returns:
object on which this method was invoked
Exceptions:
IllegalAddException if the collection contains objects of illegal types.
IndexOutOfBoundsException if index is negative or greater than the current number of children.

Element org::jdom::Element::setContent int  index,
Content  child
[inline]
 

Replace the current child the given index with the supplied child.

In event of an exception the original content will be unchanged and the supplied child will be unaltered.

Parameters:
index - index of child to replace.
child - child to add.
Returns:
element on which this method was invoked
Exceptions:
IllegalAddException if the supplied child is already attached or not legal content for this parent.
IndexOutOfBoundsException if index is negative or greater than the current number of children.

Element org::jdom::Element::setContent Collection  newContent  )  [inline]
 

This sets the content of the element. The supplied List should contain only objects of type Element, Text, CDATA, Comment, ProcessingInstruction, and EntityRef.

When all objects in the supplied List are legal and before the new content is added, all objects in the old content will have their parentage set to null (no parent) and the old content list will be cleared. This has the effect that any active list (previously obtained with a call to getContent or getChildren) will also change to reflect the new content. In addition, all objects in the supplied List will have their parentage set to this element, but the List itself will not be "live" and further removals and additions will have no effect on this elements content. If the user wants to continue working with a "live" list, then a call to setContent should be followed by a call to getContent or getChildren to obtain a "live" version of the content.

Passing a null or empty List clears the existing content.

In event of an exception the original content will be unchanged and the objects in the supplied content will be unaltered.

Parameters:
newContent List of content to set
Returns:
this element modified
Exceptions:
IllegalAddException if the List contains objects of illegal types or with existing parentage.

Element org::jdom::Element::setName String  name  )  [inline]
 

Sets the (local) name of the element.

Parameters:
name the new (local) name of the element
Returns:
the target element
Exceptions:
IllegalNameException if the given name is illegal as an Element name

Element org::jdom::Element::setNamespace Namespace  namespace  )  [inline]
 

Sets the element's Namespace. If the provided namespace is null, the element will have no namespace.

Parameters:
namespace the new namespace
Returns:
the target element

Element org::jdom::Element::setText String  text  )  [inline]
 

Sets the content of the element to be the text given. All existing text content and non-text context is removed. If this element should have both textual content and nested elements, use setContent instead. Setting a null text value is equivalent to setting an empty string value.

Parameters:
text new text content for the element
Returns:
the target element
Exceptions:
IllegalDataException if the assigned text contains an illegal character such as a vertical tab (as determined by org.jdom.Verifier#checkCharacterData)

String org::jdom::Element::toString  )  [inline]
 

This returns a String representation of the Element, suitable for debugging. If the XML representation of the Element is desired, org.jdom.output.XMLOutputter#outputString(Element) should be used.

Returns:
String - information about the Element


Member Data Documentation

transient List org::jdom::Element::additionalNamespaces [protected]
 

Additional namespace declarations to store on this element; useful during output

AttributeList org::jdom::Element::attributes = new AttributeList(this) [package]
 

The attributes of the element. Subclassers have to track attributes using their own mechanism.

ContentList org::jdom::Element::content = new ContentList(this) [package]
 

The content of the element. Subclassers have to track content using their own mechanism.

String org::jdom::Element::name [protected]
 

The local name of the element


The documentation for this class was generated from the following file:
Generated on Thu Dec 9 10:42:04 2004 for JDOM by  doxygen 1.3.9.1