Public Methods | |
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 () |
Element | getParent () |
Element | detach () |
boolean | isRootElement () |
Document | getDocument () |
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 () |
Element | setContent (List newContent) |
boolean | hasChildren () |
List | getChildren () |
Element | setChildren (List children) |
List | getChildren (String name) |
List | getChildren (String name, Namespace ns) |
Element | getChild (String name, Namespace ns) |
Element | getChild (String name) |
Element | addContent (String str) |
Element | addContent (Text text) |
Element | addContent (CDATA cdata) |
Element | addContent (Element element) |
Element | addContent (ProcessingInstruction pi) |
Element | addContent (EntityRef entity) |
Element | addContent (Comment comment) |
boolean | isAncestor (Element element) |
boolean | removeChild (String name) |
boolean | removeChild (String name, Namespace ns) |
boolean | removeChildren (String name) |
boolean | removeChildren (String name, Namespace ns) |
boolean | removeChildren () |
List | getAttributes () |
Attribute | getAttribute (String name) |
Attribute | getAttribute (String name, Namespace ns) |
String | getAttributeValue (String name) |
String | getAttributeValue (String name, Namespace ns) |
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) |
boolean | removeContent (Element element) |
boolean | removeContent (ProcessingInstruction pi) |
boolean | removeContent (Comment comment) |
boolean | removeContent (CDATA cdata) |
boolean | removeContent (Text text) |
boolean | removeContent (EntityRef entity) |
String | toString () |
final boolean | equals (Object ob) |
final int | hashCode () |
Object | clone () |
Protected Methods | |
Element () | |
Element | setParent (Element parent) |
Element | setDocument (Document document) |
Protected Attributes | |
String | name |
transient List | additionalNamespaces |
Object | parent |
AttributeList | attributes = new AttributeList(this) |
ContentList | content = new ContentList(this) |
Element
defines behavior for an XML element, modeled in Java. Methods allow the user to obtain the value of the element's textual content, obtain its attributes, and get its children.
|
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 |
|
This will create an
|
|
This will create a new
|
|
This will create a new
|
|
This adds a comment as content to this element.
|
|
This adds entity content to this element.
|
|
This adds a processing instruction as content to this element.
|
|
This adds element content to this element.
|
|
This adds a CDATA section as content to this element.
|
|
This adds text content to this element. It does not replace the existing content as does
|
|
This adds text content to this element. It does not replace the existing content as does
|
|
This will add 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.
|
|
This returns a deep clone of this element. The new element is detached from its parent, and getParent() on the clone will return null.
|
|
This detaches the element from its parent, or does nothing if the element has no parent.
|
|
This tests for equality of this
|
|
This will return any namespace declarations on this element that exist, excluding the namespace of the element itself, which can be obtained through
|
|
This returns the attribute for this element with the given name and within the given Namespace, or null if no such attribute exists.
|
|
This returns the attribute for this element with the given name and within no namespace, or null if no such attribute exists.
|
|
This returns the complete set of attributes for this element, as a
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
This returns a
Please see the notes for
|
|
This returns a
Please see the notes for
|
|
This returns a
Since getChildren always returns a "live" and modifiable list, even if the element contains no children, performance conscious users should call hasChildren first to check for content.
No recursion is performed, so elements nested two levels deep would have to be obtained with:
|
|
This convenience method returns the textual content of the named child element, or returns null if there's no such child.
|
|
This convenience method returns the textual content of the named child element, or returns an empty
|
|
This convenience method returns the normalized textual content of the named child element, or returns null if there's no such child. See
|
|
This convenience method returns the normalized textual content of the named child element, or returns null if there's no such child. See
|
|
This convenience method returns the trimmed textual content of the named child element, or returns null if there's no such child. See
|
|
This convenience method returns the trimmed textual content of the named child element, or returns null if there's no such child. See
|
|
This returns the full content of the element as a List which may contain objects of type
|
|
This retrieves the owning
|
|
This returns the (local) name of the
|
|
This returns the Namespace in scope on this element for the given prefix (this involves searching up the tree, so the results depend on the current location of the element). It returns null if there is no Namespace in scope with the given prefix at this point in the document.
|
|
This will return this
|
|
This returns the namespace prefix of the
|
|
This returns the URI mapped to this
|
|
This will return the parent of this
|
|
This returns the full name of the
|
|
This returns the textual content directly held under this element. This will include all text within this single element, including whitespace and CDATA sections if they exist. It's essentially the concatenation of all
|
|
This 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.
|
|
This 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.
|
|
Test whether this element has a child element. This method can be used before a call to getContent, which always creates a "live" list, to improve performance.
|
|
This returns the hash code for this
|
|
Determines if this element is the ancestor of another element.
|
|
This returns a
|
|
This removes the supplied Attribute should it exist.
|
|
This removes the attribute with the given name and within the given Namespace. If no such attribute exists, this method does nothing.
|
|
This removes the attribute with the given name and within no namespace. If no such attribute exists, this method does nothing.
|
|
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.
|
|
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.
|
|
This removes all child elements. Returns true if any were removed.
|
|
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.
|
|
This removes all child elements (one level deep) with the given local name and belonging to no namespace. Returns true if any were removed.
|
|
This removes the specified
|
|
This removes the specified
|
|
This removes the specified
|
|
This removes the specified
|
|
This removes the specified
|
|
This removes the specified
|
|
This will remove a 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.
|
|
This sets an attribute value for this element. Any existing attribute with the same name and namespace URI is removed.
|
|
This sets an attribute value for this element. Any existing attribute with the same name and namespace URI is removed.
|
|
This sets an attribute value for this element. Any existing attribute with the same name and namespace URI is removed.
|
|
This sets the attributes of the element. The supplied List should contain only objects of type
When all objects in the supplied List are valid and before the new attributes is added, all objects in the old attributes will have their parentage set to null (no parent) and the old attributes 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 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 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 sequentially.
In event of an exception the original attributes will be unchanged and the objects in the supplied attributes will be unaltered.
|
|
This sets the content of the element the same as setContent, except only
|
|
This sets the content of the element. The supplied List should contain only objects of type
When all objects in the supplied List are valid 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.
|
|
This sets the
|
|
This sets the (local) name of the
|
|
This sets this
|
|
This will set the parent of this
|
|
This 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
|
|
This returns a
|
|
Additional |
|
The attributes of the |
|
The mixed content of the |
|
The local name of the |
|
Parent element, document, or null if none |