|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jdom.Element
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.
Field Summary | |
protected java.util.List |
additionalNamespaces
Additional declarations on this
element |
protected org.jdom.AttributeList |
attributes
The attributes of the Element . |
protected org.jdom.ContentList |
content
The mixed content of the Element . |
protected java.lang.String |
name
The local name of the Element |
protected Namespace |
namespace
The of the Element |
protected java.lang.Object |
parent
Parent element, document, or null if none |
Constructor Summary | |
protected |
Element()
This protected constructor is provided in order to support an Element subclass that wants full control over variable initialization. |
|
Element(java.lang.String name)
This will create an Element in no
. |
|
Element(java.lang.String name,
Namespace namespace)
This will create a new Element
with the supplied (local) name, and define
the to be used. |
|
Element(java.lang.String name,
java.lang.String uri)
This will create a new Element with
the supplied (local) name, and specifies the URI
of the the Element
should be in, resulting it being unprefixed (in the default
namespace). |
|
Element(java.lang.String name,
java.lang.String prefix,
java.lang.String uri)
This will create a new Element with
the supplied (local) name, and specifies the prefix and URI
of the the Element
should be in. |
Method Summary | |
Element |
addContent(Comment comment)
This adds a comment as content to this element. |
Element |
addContent(Element element)
This adds element content to this element. |
Element |
addContent(EntityRef entity)
This adds entity content to this element. |
Element |
addContent(ProcessingInstruction pi)
This adds a processing instruction as content to this element. |
Element |
addContent(java.lang.String str)
This adds text content to this element. |
Element |
addContent(Text text)
This adds text content to this element. |
void |
addNamespaceDeclaration(Namespace additional)
This will add a namespace declarations to this element. |
java.lang.Object |
clone()
This returns a deep clone of this element. |
Element |
detach()
This detaches the element from its parent, or does nothing if the element has no parent. |
boolean |
equals(java.lang.Object ob)
This tests for equality of this Element to the supplied
Object , explicitly using the == operator. |
java.util.List |
getAdditionalNamespaces()
This will return any namespace declarations on this element that exist, excluding the namespace of the element itself, which can be obtained through . |
Attribute |
getAttribute(java.lang.String name)
This returns the attribute for this element with the given name and within no namespace, or null if no such attribute exists. |
Attribute |
getAttribute(java.lang.String name,
Namespace ns)
This returns the attribute for this element with the given name and within the given Namespace, or null if no such attribute exists. |
java.util.List |
getAttributes()
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. |
java.lang.String |
getAttributeValue(java.lang.String name)
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. |
java.lang.String |
getAttributeValue(java.lang.String name,
Namespace ns)
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. |
java.lang.String |
getAttributeValue(java.lang.String name,
Namespace ns,
java.lang.String def)
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. |
java.lang.String |
getAttributeValue(java.lang.String name,
java.lang.String def)
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. |
Element |
getChild(java.lang.String name)
This returns the first child element within this element with the given local name and belonging to no namespace. |
Element |
getChild(java.lang.String name,
Namespace ns)
This returns the first child element within this element with the given local name and belonging to the given namespace. |
java.util.List |
getChildren()
This returns a List of all the child elements
nested directly (one level deep) within this element, as
Element objects. |
java.util.List |
getChildren(java.lang.String name)
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. |
java.util.List |
getChildren(java.lang.String name,
Namespace ns)
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. |
java.lang.String |
getChildText(java.lang.String name)
This convenience method returns the textual content of the named child element, or returns an empty String ("")
if the child has no textual content. |
java.lang.String |
getChildText(java.lang.String name,
Namespace ns)
This convenience method returns the textual content of the named child element, or returns null if there's no such child. |
java.lang.String |
getChildTextNormalize(java.lang.String name)
This convenience method returns the normalized textual content of the named child element, or returns null if there's no such child. |
java.lang.String |
getChildTextNormalize(java.lang.String name,
Namespace ns)
This convenience method returns the normalized textual content of the named child element, or returns null if there's no such child. |
java.lang.String |
getChildTextTrim(java.lang.String name)
This convenience method returns the trimmed textual content of the named child element, or returns null if there's no such child. |
java.lang.String |
getChildTextTrim(java.lang.String name,
Namespace ns)
This convenience method returns the trimmed textual content of the named child element, or returns null if there's no such child. |
java.util.List |
getContent()
This returns the full content of the element as a List which may contain objects of type Text , Element ,
Comment , ProcessingInstruction ,
CDATA , and EntityRef . |
java.util.List |
getContent(Filter filter)
Return a filter view of this Element 's content. |
Document |
getDocument()
This retrieves the owning for
this Element, or null if not a currently a member of a
. |
java.lang.String |
getName()
This returns the (local) name of the Element , without any
namespace prefix, if one exists. |
Namespace |
getNamespace()
This will return this Element 's
. |
Namespace |
getNamespace(java.lang.String prefix)
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). |
java.lang.String |
getNamespacePrefix()
This returns the namespace prefix of the Element , if
one exists. |
java.lang.String |
getNamespaceURI()
This returns the URI mapped to this Element 's
prefix (or the default namespace if no prefix). |
Element |
getParent()
This will return the parent of this Element . |
java.lang.String |
getQualifiedName()
This returns the full name of the Element , in the form
[namespacePrefix]:[localName]. |
java.lang.String |
getText()
This returns the textual content directly held under this element. |
java.lang.String |
getTextNormalize()
This returns the textual content of this element with all surrounding whitespace removed and internal whitespace normalized to a single space. |
java.lang.String |
getTextTrim()
This returns the textual content of this element with all surrounding whitespace removed. |
boolean |
hasChildren()
Deprecated. Deprecated in Beta 9, instead of this method you can check the size of a getChildren() call |
int |
hashCode()
This returns the hash code for this Element . |
boolean |
isAncestor(Element element)
Determines if this element is the ancestor of another element. |
boolean |
isRootElement()
This returns a boolean value indicating
whether this Element is a root
Element for a JDOM . |
boolean |
removeAttribute(Attribute attribute)
This removes the supplied Attribute should it exist. |
boolean |
removeAttribute(java.lang.String name)
This removes the attribute with the given name and within no namespace. |
boolean |
removeAttribute(java.lang.String name,
Namespace ns)
This removes the attribute with the given name and within the given Namespace. |
boolean |
removeChild(java.lang.String name)
This removes the first child element (one level deep) with the given local name and belonging to no namespace. |
boolean |
removeChild(java.lang.String name,
Namespace ns)
This removes the first child element (one level deep) with the given local name and belonging to the given namespace. |
boolean |
removeChildren()
Deprecated. Deprecated in Beta 9, instead of this method you can call clear() on the list returned by getChildren() or by
getContent() |
boolean |
removeChildren(java.lang.String name)
This removes all child elements (one level deep) with the given local name and belonging to no namespace. |
boolean |
removeChildren(java.lang.String name,
Namespace ns)
This removes all child elements (one level deep) with the given local name and belonging to the given namespace. |
boolean |
removeContent(Comment comment)
This removes the specified Comment . |
boolean |
removeContent(Element element)
This removes the specified Element . |
boolean |
removeContent(EntityRef entity)
This removes the specified EntityRef . |
boolean |
removeContent(ProcessingInstruction pi)
This removes the specified ProcessingInstruction . |
boolean |
removeContent(Text text)
This removes the specified Text . |
void |
removeNamespaceDeclaration(Namespace additionalNamespace)
This will remove a namespace declarations from this element. |
Element |
setAttribute(Attribute attribute)
This sets an attribute value for this element. |
Element |
setAttribute(java.lang.String name,
java.lang.String value)
This sets an attribute value for this element. |
Element |
setAttribute(java.lang.String name,
java.lang.String value,
Namespace ns)
This sets an attribute value for this element. |
Element |
setAttributes(java.util.List newAttributes)
This sets the attributes of the element. |
Element |
setChildren(java.util.List children)
Deprecated. Deprecated in Beta 9, use setContent(List) instead |
Element |
setContent(java.util.List newContent)
This sets the content of the element. |
protected Element |
setDocument(Document document)
This sets the parent of this element
and makes it the root element. |
Element |
setName(java.lang.String name)
This sets the (local) name of the Element . |
Element |
setNamespace(Namespace namespace)
This sets this Element 's . |
protected Element |
setParent(Element parent)
This will set the parent of this Element . |
Element |
setText(java.lang.String text)
This sets the content of the element to be the text given. |
java.lang.String |
toString()
This returns a String representation of the
Element , suitable for debugging. |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.lang.String name
Element
protected transient Namespace namespace
Namespace
of the Element
protected transient java.util.List additionalNamespaces
Namespace
declarations on this
element
protected java.lang.Object parent
protected org.jdom.AttributeList attributes
Element
.
protected org.jdom.ContentList content
Element
.
Constructor Detail |
protected Element()
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.
public Element(java.lang.String name, Namespace namespace)
Element
with the supplied (local) name, and define
the Namespace
to be used.
If the provided namespace is null, the element will have
no namespace.
name
- String
name of element.namespace
- Namespace
to put element in.
IllegalNameException
- if the given name is illegal as an
element name.public Element(java.lang.String name)
Element
in no
Namespace
.
name
- String
name of element.
IllegalNameException
- if the given name is illegal as an
element name.public Element(java.lang.String name, java.lang.String uri)
Element
with
the supplied (local) name, and specifies the URI
of the Namespace
the Element
should be in, resulting it being unprefixed (in the default
namespace).
name
- String
name of element.uri
- String
URI for Namespace
element
should be in.
IllegalNameException
- if the given name is illegal as an
element name or the given URI is illegal as a
namespace URIpublic Element(java.lang.String name, java.lang.String prefix, java.lang.String uri)
Element
with
the supplied (local) name, and specifies the prefix and URI
of the Namespace
the Element
should be in.
name
- String
name of element.uri
- String
URI for Namespace
element
should be in.
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 URIMethod Detail |
public java.lang.String getName()
Element
, without any
namespace prefix, if one exists.
String
- element name.public Element setName(java.lang.String name)
Element
.
Element
- the element modified.
IllegalNameException
- if the given name is illegal as an
Element name.public Namespace getNamespace()
Element
's
Namespace
.
Namespace
- Namespace object for this
Element
public Element setNamespace(Namespace namespace)
Element
's Namespace
.
If the provided namespace is null, the element will have no namespace.
Element
- the element modified.public java.lang.String getNamespacePrefix()
Element
, if
one exists. Otherwise, an empty
String
is returned.
String
- namespace prefix.public java.lang.String getNamespaceURI()
Element
's
prefix (or the default namespace if no prefix). If no
mapping is found, an empty String
is returned.
String
- namespace URI for this
Element
.public Namespace getNamespace(java.lang.String prefix)
prefix
- namespace prefix to look up
Namespace
- namespace in scope for the given
prefix on this Element
, or null if none.public java.lang.String getQualifiedName()
Element
, in the form
[namespacePrefix]:[localName]. If
the Element
does not have a namespace prefix,
then the local name is returned.
String
- full name of element.public void addNamespaceDeclaration(Namespace additional)
additional
- Namespace
to add.
IllegalAddException
- if the namespace prefix collides with
another namespace prefix on the element.public void removeNamespaceDeclaration(Namespace additionalNamespace)
additionalNamespace
- Namespace
to remove.public java.util.List getAdditionalNamespaces()
getNamespace()
. If there are no additional
declarations, this returns an empty list. Note, the returned
list is not live, for performance reasons.
List
- the additional namespace declarations.public Element getParent()
Element
.
If there is no parent, then this returns null
.
Also note that on its own, this is not 100% sufficient to
see if the Element
is not in use - this should
be used in tandem with isRootElement()
to determine this.
Element
.protected Element setParent(Element parent)
Element
.
The caller is responsible for handling pre-existing parentage.
parent
- Element
to be new parent.
Element
- this Element
modified.public Element detach()
Element
- this Element
modified.public boolean isRootElement()
boolean
value indicating
whether this Element
is a root
Element
for a JDOM Document
.
This should be used in tandem with
getParent()
to determine
if an Element
has no "attachments" to
parents.
boolean
- whether this is a root element.protected Element setDocument(Document document)
Document
parent of this element
and makes it the root element. The caller is responsible for
ensuring the element doesn't have a pre-existing parent.
document
- Document
parent
Document
this Element
modifiedpublic Document getDocument()
Document
for
this Element, or null if not a currently a member of a
Document
.
Document
owning this Element, or null.public java.lang.String getText()
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.
public java.lang.String getTextTrim()
public java.lang.String getTextNormalize()
public java.lang.String getChildText(java.lang.String name)
String
("")
if the child has no textual content. However, if the child does
not exist, null
is returned.
name
- the name of the child
public java.lang.String getChildTextTrim(java.lang.String name)
getTextTrim()
for details of text trimming.
name
- the name of the child
public java.lang.String getChildTextNormalize(java.lang.String name)
getTextNormalize()
for details of text
normalizing.
name
- the name of the child
public java.lang.String getChildText(java.lang.String name, Namespace ns)
name
- the name of the childns
- the namespace of the child
public java.lang.String getChildTextTrim(java.lang.String name, Namespace ns)
getTextTrim()
for
details of text trimming.
name
- the name of the childns
- the namespace of the child
public java.lang.String getChildTextNormalize(java.lang.String name, Namespace ns)
getTextNormalize()
for
details of text normalizing.
name
- the name of the childns
- the namespace of the child
public Element setText(java.lang.String text)
setContent(java.util.List)
instead.
Setting a null text value is equivalent to setting an empty string
value.
text
- new content for the element
IllegalDataException
- if text
contains an
illegal character such as a vertical tab (as determined
by Verifier.checkCharacterData(java.lang.String)
)public java.util.List getContent()
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.
List
containing the mixed content of the
element: may contain Text
,
Element
, Comment
,
ProcessingInstruction
,
CDATA
, and
EntityRef
objects.public java.util.List getContent(Filter filter)
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.
filter
- Filter
to apply
List
- filtered Element contentpublic Element setContent(java.util.List newContent)
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.
newContent
- List
of content to set
IllegalAddException
- if the List contains objects of
illegal types.public java.util.List getChildren()
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
}
Element
objects for this elementpublic java.util.List getChildren(java.lang.String name)
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
for a code example.
getChildren()
name
- local name for the children to match
public java.util.List getChildren(java.lang.String name, Namespace ns)
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
for a code example.
getChildren()
name
- local name for the children to matchns
- Namespace
to search within
public Element getChild(java.lang.String name, Namespace ns)
name
- local name of child element to matchns
- Namespace
to search within
public Element getChild(java.lang.String name)
name
- local name of child element to match
public Element addContent(java.lang.String str)
setText()
.
str
- String
to add
IllegalDataException
- if str
contains an
illegal character such as a vertical tab (as determined
by Verifier.checkCharacterData(java.lang.String)
)public Element addContent(Text text)
setText()
.
text
- Text
to add
IllegalAddException
- if the Text
object
you're attempting to add already has a parent element.public Element addContent(Element element)
element
- Element
to add
IllegalAddException
- if the element you're attempting to
add already has a parent element, or if you're attempting
to add it as a descendent of itself (which would result in
a recursive element definition!).public Element addContent(ProcessingInstruction pi)
pi
- ProcessingInstruction
to add
IllegalAddException
- if the given processing instruction,
pi
, already has a parent.public Element addContent(EntityRef entity)
entity
- EntityRef
to add
IllegalAddException
- if the given EntityRef already has a
parent.public Element addContent(Comment comment)
comment
- Comment
to add
IllegalAddException
- if the given Comment already has a
parent.public boolean isAncestor(Element element)
element
- Element
to check against
true
if this element is the ancestor of the
supplied elementpublic boolean removeChild(java.lang.String name)
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.
name
- the name of child elements to remove
public boolean removeChild(java.lang.String name, Namespace ns)
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.
name
- the name of child element to removens
- Namespace
to search within
public boolean removeChildren(java.lang.String name)
This removes all child elements (one level deep) with the given local name and belonging to no namespace. Returns true if any were removed.
name
- the name of child elements to remove
public boolean removeChildren(java.lang.String name, Namespace ns)
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.
name
- the name of child elements to removens
- Namespace
to search within
public java.util.List getAttributes()
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.
public Attribute getAttribute(java.lang.String name)
This returns the attribute for this element with the given name and within no namespace, or null if no such attribute exists.
name
- name of the attribute to return
public Attribute getAttribute(java.lang.String name, Namespace ns)
This returns the attribute for this element with the given name and within the given Namespace, or null if no such attribute exists.
name
- name of the attribute to returnns
- Namespace
to search within
public java.lang.String getAttributeValue(java.lang.String name)
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.
name
- name of the attribute whose value to be returned
public java.lang.String getAttributeValue(java.lang.String name, Namespace ns, java.lang.String def)
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.
name
- name of the attribute whose valud is to be returnedns
- Namespace
to search withindef
- a default value to return if the attribute does not exist
public java.lang.String getAttributeValue(java.lang.String name, java.lang.String def)
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.
name
- name of the attribute whose value to be returneddef
- a default value to return if the attribute does not exist
public java.lang.String getAttributeValue(java.lang.String name, Namespace ns)
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.
name
- name of the attribute whose valud is to be returnedns
- Namespace
to search within
public Element setAttributes(java.util.List newAttributes)
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.
newAttributes
- List
of attributes to set
IllegalAddException
- if the List contains objects
that are not instances of Attribute
,
or if any of the Attribute
objects have
conflicting namespace prefixes.public Element setAttribute(java.lang.String name, java.lang.String value)
This sets an attribute value for this element. Any existing attribute with the same name and namespace URI is removed.
name
- name of the attribute to setvalue
- value of the attribute to set
IllegalNameException
- if the given name is illegal as an
attribute name.
IllegalDataException
- if the given attribute value is
illegal character data (as determined by
Verifier.checkCharacterData(java.lang.String)
).public Element setAttribute(java.lang.String name, java.lang.String value, Namespace ns)
This sets an attribute value for this element. Any existing attribute with the same name and namespace URI is removed.
name
- name of the attribute to setvalue
- value of the attribute to setns
- namespace of the attribute to set
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
Verifier.checkCharacterData(java.lang.String)
).
IllegalAddException
- if the attribute namespace prefix
collides with another namespace prefix on the element.public Element setAttribute(Attribute attribute)
This sets an attribute value for this element. Any existing attribute with the same name and namespace URI is removed.
attribute
- Attribute
to set
IllegalAddException
- if the attribute being added already has a
parent or if the attribute namespace prefix collides with another
namespace prefix on the element.public boolean removeAttribute(java.lang.String name)
This removes the attribute with the given name and within no namespace. If no such attribute exists, this method does nothing.
name
- name of attribute to remove
public boolean removeAttribute(java.lang.String name, Namespace ns)
This removes the attribute with the given name and within the given Namespace. If no such attribute exists, this method does nothing.
name
- name of attribute to removens
- namespace URI of attribute to remove
public boolean removeAttribute(Attribute attribute)
This removes the supplied Attribute should it exist.
attribute
- Reference to the attribute to be removed.
public boolean removeContent(Element element)
This removes the specified Element
.
If the specified Element
is not a child of
this Element
, this method does nothing.
element
- Element
to delete
public boolean removeContent(ProcessingInstruction pi)
This removes the specified ProcessingInstruction
.
If the specified ProcessingInstruction
is not a child of
this Element
, this method does nothing.
pi
- ProcessingInstruction
to delete
public boolean removeContent(Comment comment)
This removes the specified Comment
.
If the specified Comment
is not a child of
this Element
, this method does nothing.
comment
- Comment
to delete
public boolean removeContent(Text text)
This removes the specified Text
.
If the specified Text
is not a child of
this Element
, this method does nothing.
text
- Text
to delete
public boolean removeContent(EntityRef entity)
This removes the specified EntityRef
.
If the specified EntityRef
is not a child of
this Element
, this method does nothing.
entity
- EntityRef
to delete
public java.lang.String toString()
This returns a String
representation of the
Element
, suitable for debugging. If the XML
representation of the Element
is desired,
XMLOutputter.outputString(Element)
should be used.
toString
in class java.lang.Object
String
- information about the
Element
public final boolean equals(java.lang.Object ob)
This tests for equality of this Element
to the supplied
Object
, explicitly using the == operator.
equals
in class java.lang.Object
ob
- Object
to compare to
public final int hashCode()
This returns the hash code for this Element
.
hashCode
in class java.lang.Object
public java.lang.Object clone()
This returns a deep clone of this element. The new element is detached from its parent, and getParent() on the clone will return null.
clone
in class java.lang.Object
public boolean removeChildren()
clear()
on the list returned by getChildren()
or by
getContent()
This removes all child elements. Returns true if any were removed.
public boolean hasChildren()
getContent()
,
which always creates a "live" list, to improve performance.
true
if this element has at least
one child elementpublic Element setChildren(java.util.List children)
setContent(java.util.List)
,
except only Element
objects are allowed in the supplied
list.
children
- List
of Element
objects to add
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |