public abstract class AbstractElement extends AbstractBranch implements Element
AbstractElement
is an abstract base class for
tree implementors to use for implementation inheritence.
Modifier and Type | Field and Description |
---|---|
private static DocumentFactory |
DOCUMENT_FACTORY
The
DocumentFactory instance used by default |
protected static Iterator |
EMPTY_ITERATOR |
protected static List |
EMPTY_LIST |
protected static boolean |
USE_STRINGVALUE_SEPARATOR |
protected static boolean |
VERBOSE_TOSTRING |
DEFAULT_CONTENT_LIST_SIZE, outputFormat
NODE_TYPE_NAMES
ANY_NODE, ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_REFERENCE_NODE, MAX_NODE_TYPE, NAMESPACE_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE, UNKNOWN_NODE
Constructor and Description |
---|
AbstractElement() |
Modifier and Type | Method and Description |
---|---|
void |
accept(Visitor visitor)
accept method is the Visitor Pattern method. |
void |
add(Attribute attribute)
Adds the given
Attribute to this element. |
void |
add(CDATA cdata)
Adds the given
CDATA to this element. |
void |
add(Comment comment)
Adds the given
Comment to this branch. |
void |
add(Element element)
Adds the given
Element to this branch. |
void |
add(Entity entity)
Adds the given
Entity to this element. |
void |
add(Namespace namespace)
Adds the given
Namespace to this element. |
void |
add(Node node)
Adds the given
Node or throws IllegalAddException
if the given node is not of a valid type. |
void |
add(ProcessingInstruction pi)
Adds the given
ProcessingInstruction to this branch. |
void |
add(Text text)
Adds the given
Text to this element. |
Element |
addAttribute(QName qName,
String value)
Adds the attribute value of the given fully qualified name.
|
Element |
addAttribute(String name,
String value)
Adds the attribute value of the given local name.
|
Element |
addCDATA(String cdata)
Adds a new
CDATA node with the given text to this element. |
Element |
addComment(String comment)
Adds a new
Comment node with the given text to this element. |
Element |
addElement(String name)
Adds a new
Element node with the given name to this branch
and returns a reference to the new node. |
Element |
addEntity(String name,
String text)
Adds a new
Entity node with the given name and text
to this element and returns a reference to the new node. |
List |
additionalNamespaces()
Returns any additional namespaces declarations for this element
other than namespace returned via the
Element.getNamespace() method. |
List |
additionalNamespaces(String defaultNamespaceURI) |
Element |
addNamespace(String prefix,
String uri)
Adds a namespace to this element for use by its child content
|
protected void |
addNewNode(Node node)
Like addNode() but does not require a parent check
|
protected void |
addNode(Node node) |
Element |
addProcessingInstruction(String target,
Map data)
Adds a processing instruction for the given target
|
Element |
addProcessingInstruction(String target,
String data)
Adds a processing instruction for the given target
|
Element |
addText(String text)
Adds a new
Text node with the given text to this element. |
void |
appendAttributes(Element element)
Appends the attributes of the given element to me.
|
String |
asXML()
asXML returns the textual XML representation of this
node. |
Attribute |
attribute(int index)
Returns the attribute at the specified indexGets the
|
Attribute |
attribute(QName qName) |
Attribute |
attribute(String name)
Returns the attribute with the given name
|
Attribute |
attribute(String name,
Namespace namespace) |
int |
attributeCount() |
Iterator |
attributeIterator() |
protected abstract List |
attributeList() |
protected abstract List |
attributeList(int attributeCount) |
List |
attributes()
|
String |
attributeValue(QName qName)
This returns the attribute value for the attribute with the
given fully qualified name or null if there is no such
attribute or the empty string if the attribute value is empty.
|
String |
attributeValue(QName qName,
String defaultValue)
This returns the attribute value for the attribute with the
given fully qualified name or the default value if
there is no such attribute value.
|
String |
attributeValue(String name)
This returns the attribute value for the attribute with the
given name and any namespace or null if there is no such
attribute or the empty string if the attribute value is empty.
|
String |
attributeValue(String name,
String defaultValue)
This returns the attribute value for the attribute with the
given name and any namespace or the default value if there is
no such attribute value.
|
protected void |
childAdded(Node node)
Called when a new child node is added to
create any parent relationships
|
protected void |
childRemoved(Node node)
Called when a child node has been removed
to allow any parent relationships to be deleted or
events to be fired.
|
protected List |
createAttributeList()
A Factory Method pattern which creates
a List implementation used to store attributes
|
protected List |
createAttributeList(int size)
A Factory Method pattern which creates
a List implementation used to store attributes
|
Element |
createCopy()
This returns a deep clone of this element.
|
Element |
createCopy(QName qName)
Creates a deep copy of this element with the given fully qualified name.
|
Element |
createCopy(String name)
Creates a deep copy of this element with the given local name
The new element is detached from its parent, and getParent() on the
clone will return null.
|
protected Element |
createElement(QName qName) |
protected Element |
createElement(String name) |
protected Iterator |
createSingleIterator(Object result) |
List |
declaredNamespaces()
Returns all the namespaces declared by this element.
|
Element |
element(QName qName)
Returns the first element for the given fully qualified name.
|
Element |
element(String name)
Returns the first element for the given local name and any namespace.
|
Element |
element(String name,
Namespace namespace) |
Iterator |
elementIterator()
Returns an iterator over all this elements child elements.
|
Iterator |
elementIterator(QName qName)
Returns an iterator over the elements contained in this element
which match the given fully qualified name.
|
Iterator |
elementIterator(String name)
Returns an iterator over the elements contained in this element
which match the given local name and any namespace.
|
Iterator |
elementIterator(String name,
Namespace namespace) |
List |
elements()
Returns the elements contained in this element.
|
List |
elements(QName qName)
Returns the elements contained in this element with the given
fully qualified name.
|
List |
elements(String name)
Returns the elements contained in this element with the given
local name and any namespace.
|
List |
elements(String name,
Namespace namespace) |
String |
elementText(QName qName) |
String |
elementText(String name) |
String |
elementTextTrim(QName qName) |
String |
elementTextTrim(String name) |
void |
ensureAttributesCapacity(int minCapacity)
Ensures that the list of attributes has the given size
|
Object |
getData()
Accesses the data of this element which may implement data typing
bindings such as XML Schema or
Java Bean bindings or will return the same value as
Element.getText() |
protected DocumentFactory |
getDocumentFactory() |
String |
getName()
getName returns the name of this node. |
Namespace |
getNamespace()
Returns the
Namespace of this element if one exists
otherwise Namespace.NO_NAMESPACE is returned. |
Namespace |
getNamespaceForPrefix(String prefix)
Returns the
Namespace which is mapped to the given
prefix or null if it could not be found. |
Namespace |
getNamespaceForURI(String uri)
Returns the
Namespace which is mapped to the given
URI or null if it could not be found. |
String |
getNamespacePrefix()
Returns the namespace prefix of this element if one exists
otherwise an empty
String is returned. |
String |
getNamespaceURI()
Returns the URI mapped to the namespace of this element
if one exists otherwise an empty
String is returned. |
short |
getNodeType()
Returns the code according to the type of node.
|
String |
getPath(Element context)
Returns the relative XPath expression which will return a node set
containing the given node such as a/b/@c.
|
QName |
getQName(String qualifiedName)
Returns the
QName for the given qualified name, using
the namespace URI in scope for the given prefix of the qualified name
or the default namespace if the qualified name has no prefix. |
String |
getQualifiedName()
Returns the fully qualified name of this element.
|
String |
getStringValue()
Returns the XPath string-value of this node.
|
String |
getUniquePath(Element context)
Returns the relative unique XPath expression from the given context
which will return a nodeset
of one node which is the current node.
|
String |
getXPathNameStep()
Returns the XPath expression to match this Elements name
which is getQualifiedName() if there is a namespace prefix defined or
if no namespace is present then it is getName() or if a namespace is defined
with no prefix then the expression is *[name()='X'] where X = getName().
|
Node |
getXPathResult(int index)
Returns a node at the given index suitable for an XPath result set.
|
boolean |
hasMixedContent()
Returns true if this
Element has mixed content. |
int |
indexOf(Node node)
Returns the index of the given node if it is a child node of this
branch or -1 if the given node is not a child node.
|
boolean |
isRootElement() |
boolean |
isTextOnly()
Returns true if this
Element has text only content. |
Node |
node(int index)
Returns the
Node at the specified index position. |
int |
nodeCount()
Returns the number of
Node instances that this branch
contains. |
Iterator |
nodeIterator()
Returns an iterator through the content nodes of this branch
|
void |
normalize()
Puts all
Text nodes in the full depth of the sub-tree
underneath this Node , including attribute nodes, into a
"normal" form where only structure (e.g., elements, comments,
processing instructions, CDATA sections, and entity references)
separates Text nodes, i.e., there are neither adjacent
Text nodes nor empty Text nodes. |
ProcessingInstruction |
processingInstruction(String target) |
List |
processingInstructions()
Returns a list of all the processing instructions in this branch.
|
List |
processingInstructions(String target)
Returns a list of the processing instructions for the given target.
|
boolean |
remove(Attribute attribute)
Removes the given
Attribute from this element. |
boolean |
remove(CDATA cdata)
Removes the given
CDATA if the node is
an immediate child of this element. |
boolean |
remove(Comment comment)
Removes the given
Comment if the node is
an immediate child of this branch. |
boolean |
remove(Element element)
Removes the given
Element if the node is
an immediate child of this branch. |
boolean |
remove(Entity entity)
Removes the given
Entity if the node is
an immediate child of this element. |
boolean |
remove(Namespace namespace)
Removes the given
Namespace if the node is
an immediate child of this element. |
boolean |
remove(Node node)
Removes the given
Node if the node is
an immediate child of this branch. |
boolean |
remove(ProcessingInstruction pi)
Removes the given
ProcessingInstruction if the node is
an immediate child of this branch. |
boolean |
remove(Text text)
Removes the given
Text if the node is
an immediate child of this element. |
protected boolean |
removeNode(Node node) |
boolean |
removeProcessingInstruction(String target)
Removes the processing instruction for the given target if it exists
|
void |
setAttributes(Attributes attributes,
NamespaceStack namespaceStack,
boolean noNamespaceAttributes)
This method provides a more optimal way of setting all the attributes
on an Element particularly for use in
SAXReader . |
void |
setAttributeValue(QName qName,
String value)
Sets the attribute value of the given fully qualified name.
|
void |
setAttributeValue(String name,
String value)
Sets the attribute value of the given local name.
|
void |
setData(Object data)
Sets the data value of this element if this element supports data
binding or calls
Node.setText(java.lang.String) if it doesn't |
void |
setName(String name)
Sets the text data of this node or this method will
throw an
UnsupportedOperationException if it is
read-only. |
void |
setNamespace(Namespace namespace) |
void |
setText(String text)
Sets the text data of this node or this method will
throw an
UnsupportedOperationException if it is
read-only. |
String |
toString() |
void |
write(Writer out)
write writes this node as the default XML
notation for this node. |
addElement, addElement, addElement, appendContent, content, contentList, contentRemoved, createContentList, createContentList, createEmptyList, createResultList, createSingleResultList, elementByID, elementID, getContentAsStringValue, getContentAsText, getText, getTextTrim, hasContent, invalidNodeTypeAddException, isReadOnly, setProcessingInstructions
asXPathResult, clone, createPattern, createXPath, createXPathFilter, createXPathResult, detach, getDocument, getNodeTypeName, getParent, getPath, getUniquePath, matches, numberValueOf, selectNodes, selectNodes, selectNodes, selectObject, selectSingleNode, setDocument, setParent, supportsParent, valueOf
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getQName, getText, getTextTrim, setAttributes, setQName
addElement, addElement, appendContent, clearContent, content, elementByID, setContent, setProcessingInstructions
asXPathResult, clone, createXPath, detach, getDocument, getNodeTypeName, getParent, getPath, getUniquePath, hasContent, isReadOnly, matches, numberValueOf, selectNodes, selectNodes, selectNodes, selectObject, selectSingleNode, setDocument, setParent, supportsParent, valueOf
private static final DocumentFactory DOCUMENT_FACTORY
DocumentFactory
instance used by defaultprotected static final List EMPTY_LIST
protected static final Iterator EMPTY_ITERATOR
protected static final boolean VERBOSE_TOSTRING
protected static final boolean USE_STRINGVALUE_SEPARATOR
public AbstractElement()
public short getNodeType()
Node
getNodeType
in interface Node
getNodeType
in class AbstractNode
public boolean isRootElement()
isRootElement
in interface Element
public void setName(String name)
Node
Sets the text data of this node or this method will
throw an UnsupportedOperationException
if it is
read-only.
setName
in interface Node
setName
in class AbstractNode
name
- is the new name of this nodepublic void setNamespace(Namespace namespace)
public String getXPathNameStep()
public String getPath(Element context)
Node
Returns the relative XPath expression which will return a node set containing the given node such as a/b/@c. No indexing will be used to restrict the path if multiple elements with the same name occur on the path.
getPath
in interface Node
context
- is the parent context from which the relative path should
start. If the context is null or the context is not an ancestor of
this node then the path will be absolute and start from the document and so
begin with the '/' character.public String getUniquePath(Element context)
Node
Returns the relative unique XPath expression from the given context which will return a nodeset of one node which is the current node. This method will use the XPath index operator to restrict the path if multiple elements with the same name occur on the path.
getUniquePath
in interface Node
context
- is the parent context from which the path should
start. If the context is null or the context is not an ancestor of
this node then the path will start from the document and so
begin with the '/' character.public String asXML()
Node
asXML
returns the textual XML representation of this
node.
public void write(Writer out) throws IOException
Node
write
writes this node as the default XML
notation for this node. If you wish to control the XML output
(such as for pretty printing, changing the indentation policy etc.)
then please use XMLWriter
or its derivations.
write
in interface Node
write
in class AbstractNode
out
- is the Writer
to output the XML toIOException
public Namespace getNamespace()
Element
Returns the Namespace
of this element if one exists
otherwise Namespace.NO_NAMESPACE
is returned.
getNamespace
in interface Element
Namespace
associated with this elementpublic String getName()
Node
getName
returns the name of this node.
This is the XML local name of the element, attribute, entity or
processing instruction.
For CDATA and Text nodes this method will return null.
getName
in interface Node
getName
in class AbstractNode
public String getNamespacePrefix()
Element
Returns the namespace prefix of this element if one exists
otherwise an empty String
is returned.
getNamespacePrefix
in interface Element
Namespace
of this element
or an empty String
public String getNamespaceURI()
Element
Returns the URI mapped to the namespace of this element
if one exists otherwise an empty String
is returned.
getNamespaceURI
in interface Element
Namespace
of this element
or an empty String
public String getQualifiedName()
Element
Returns the fully qualified name of this element.
This will be the same as the value returned from Node.getName()
if this element has no namespace attached to this element or an
expression of the form
getNamespacePrefix() + ":" + getName()will be returned.
getQualifiedName
in interface Element
public Object getData()
Element
Element.getText()
public void setData(Object data)
Element
Node.setText(java.lang.String)
if it doesn'tpublic Node node(int index)
Branch
Node
at the specified index position.node
in interface Branch
node
in class AbstractBranch
index
- the index of the node to return.Node
at the specified position.public int indexOf(Node node)
Branch
indexOf
in interface Branch
indexOf
in class AbstractBranch
node
- the content child node to find.public int nodeCount()
Branch
Node
instances that this branch
contains.nodeCount
in interface Branch
nodeCount
in class AbstractBranch
public Iterator nodeIterator()
Branch
nodeIterator
in interface Branch
nodeIterator
in class AbstractBranch
public Element element(String name)
Element
public Element element(QName qName)
Element
public List elements()
Element
Returns the elements contained in this element. If this element does not contain any elements then this method returns an empty list. The list is backed by the element such that changes to the list will be reflected in the element though the reverse is not the case.
public List elements(String name)
Element
Returns the elements contained in this element with the given local name and any namespace. If no elements are found then this method returns an empty list. The list is backed by the element such that changes to the list will be reflected in the element though the reverse is not the case.
public List elements(QName qName)
Element
Returns the elements contained in this element with the given fully qualified name. If no elements are found then this method returns an empty list. The list is backed by the element such that changes to the list will be reflected in the element though the reverse is not the case.
public Iterator elementIterator()
Element
elementIterator
in interface Element
public Iterator elementIterator(String name)
Element
elementIterator
in interface Element
public Iterator elementIterator(QName qName)
Element
elementIterator
in interface Element
public Iterator elementIterator(String name, Namespace namespace)
public List attributes()
Element
Returns the Attribute
instances this element contains as
a backed List
so that the attributes may be modified directly
using the List
interface.
The List
is backed by the Element
so that
changes to the list are reflected in the element and vice versa.
attributes
in interface Element
List
public Iterator attributeIterator()
attributeIterator
in interface Element
public Attribute attribute(int index)
Element
public int attributeCount()
attributeCount
in interface Element
public Attribute attribute(String name)
Element
public void setAttributes(Attributes attributes, NamespaceStack namespaceStack, boolean noNamespaceAttributes)
SAXReader
.public String attributeValue(String name)
Element
This returns the attribute value for the attribute with the given name and any namespace or null if there is no such attribute or the empty string if the attribute value is empty.
attributeValue
in interface Element
name
- is the name of the attribute value to be returndpublic String attributeValue(QName qName)
Element
This returns the attribute value for the attribute with the given fully qualified name or null if there is no such attribute or the empty string if the attribute value is empty.
attributeValue
in interface Element
qName
- is the fully qualified namepublic String attributeValue(String name, String defaultValue)
Element
This returns the attribute value for the attribute with the given name and any namespace or the default value if there is no such attribute value.
attributeValue
in interface Element
name
- is the name of the attribute value to be returnddefaultValue
- is the default value to be returned if the
attribute has no value defined.public String attributeValue(QName qName, String defaultValue)
Element
This returns the attribute value for the attribute with the given fully qualified name or the default value if there is no such attribute value.
attributeValue
in interface Element
qName
- is the fully qualified namedefaultValue
- is the default value to be returned if the
attribute has no value defined.public void setAttributeValue(String name, String value)
Element
Sets the attribute value of the given local name.
setAttributeValue
in interface Element
name
- is the name of the attribute whose value is to be added
or updatedvalue
- is the attribute's valuepublic void setAttributeValue(QName qName, String value)
Element
Sets the attribute value of the given fully qualified name.
setAttributeValue
in interface Element
qName
- is the fully qualified name of the attribute
whose value is to be added or updatedvalue
- is the attribute's valuepublic void add(Attribute attribute)
Element
Attribute
to this element.
If the given node already has a parent defined then an
InvalidAddNodeException
will be thrown.public boolean remove(Attribute attribute)
Element
Attribute
from this element.public List processingInstructions()
Branch
Returns a list of all the processing instructions in this branch. The list is backed by this branch so that changes to the list will be reflected in the branch but the reverse is not the case.
processingInstructions
in interface Branch
public List processingInstructions(String target)
Branch
Returns a list of the processing instructions for the given target. The list is backed by this branch so that changes to the list will be reflected in the branch but the reverse is not the case.
processingInstructions
in interface Branch
public ProcessingInstruction processingInstruction(String target)
processingInstruction
in interface Branch
public boolean removeProcessingInstruction(String target)
Branch
removeProcessingInstruction
in interface Branch
public Node getXPathResult(int index)
Element
getXPathResult
in interface Element
public Element addAttribute(String name, String value)
Element
Adds the attribute value of the given local name. If an attribute already exists for the given name it will be replaced.
addAttribute
in interface Element
name
- is the name of the attribute whose value is to be added
or updatedvalue
- is the attribute's valueElement
instance.public Element addAttribute(QName qName, String value)
Element
Adds the attribute value of the given fully qualified name. If an attribute already exists for the given name it will be replaced.
addAttribute
in interface Element
qName
- is the fully qualified name of the attribute
whose value is to be added or updatedvalue
- is the attribute's valueElement
instance.public Element addCDATA(String cdata)
Element
CDATA
node with the given text to this element.public Element addComment(String comment)
Element
Comment
node with the given text to this element.addComment
in interface Element
comment
- is the text for the Comment
node.Element
instance.public Element addElement(String name)
Branch
Element
node with the given name to this branch
and returns a reference to the new node.addElement
in interface Branch
addElement
in class AbstractBranch
name
- is the name for the Element
node.Element
node.public Element addEntity(String name, String text)
Element
Entity
node with the given name and text
to this element and returns a reference to the new node.public Element addNamespace(String prefix, String uri)
Element
addNamespace
in interface Element
prefix
- is the prefix to use, which should not be null or blankuri
- is the namespace URIElement
instance.public Element addProcessingInstruction(String target, String data)
Element
addProcessingInstruction
in interface Element
target
- is the target of the processing instructiondata
- is the textual data (key/value pairs) of the processing instructionElement
instance.public Element addProcessingInstruction(String target, Map data)
Element
addProcessingInstruction
in interface Element
target
- is the target of the processing instructiondata
- is a Map of the key / value pairs of the processing instructionElement
instance.public Element addText(String text)
Element
Text
node with the given text to this element.public void add(Node node)
Branch
Node
or throws IllegalAddException
if the given node is not of a valid type. This is a polymorphic method
which will call the typesafe method for the node type such as
add(Element) or add(Comment).add
in interface Branch
add
in class AbstractBranch
node
- is the given node to addpublic boolean remove(Node node)
Branch
Node
if the node is
an immediate child of this branch.
If the given node is not an immediate child of this branch
then the Node.detach()
method should be used instead.
This is a polymorphic method which will call the typesafe method
for the node type such as remove(Element) or remove(Comment).remove
in interface Branch
remove
in class AbstractBranch
node
- is the given node to be removedpublic void add(CDATA cdata)
Element
CDATA
to this element.
If the given node already has a parent defined then an
InvalidAddNodeException
will be thrown.public void add(Comment comment)
Branch
Comment
to this branch.
If the given node already has a parent defined then an
InvalidAddNodeException
will be thrown.add
in interface Branch
add
in class AbstractBranch
comment
- is the comment to be addedpublic void add(Element element)
Branch
Element
to this branch.
If the given node already has a parent defined then an
InvalidAddNodeException
will be thrown.add
in interface Branch
add
in class AbstractBranch
element
- is the element to be addedpublic void add(Entity entity)
Element
Entity
to this element.
If the given node already has a parent defined then an
InvalidAddNodeException
will be thrown.public void add(Namespace namespace)
Element
Namespace
to this element.
If the given node already has a parent defined then an
InvalidAddNodeException
will be thrown.public void add(ProcessingInstruction pi)
Branch
ProcessingInstruction
to this branch.
If the given node already has a parent defined then an
InvalidAddNodeException
will be thrown.add
in interface Branch
add
in class AbstractBranch
pi
- is the processing instruction to be addedpublic void add(Text text)
Element
Text
to this element.
If the given node already has a parent defined then an
InvalidAddNodeException
will be thrown.public boolean remove(CDATA cdata)
Element
CDATA
if the node is
an immediate child of this element.
If the given node is not an immediate child of this element
then the Node.detach()
method should be used instead.public boolean remove(Comment comment)
Branch
Comment
if the node is
an immediate child of this branch.
If the given node is not an immediate child of this branch
then the Node.detach()
method should be used instead.remove
in interface Branch
remove
in class AbstractBranch
comment
- is the comment to be removedpublic boolean remove(Element element)
Branch
Element
if the node is
an immediate child of this branch.
If the given node is not an immediate child of this branch
then the Node.detach()
method should be used instead.remove
in interface Branch
remove
in class AbstractBranch
element
- is the element to be removedpublic boolean remove(Entity entity)
Element
Entity
if the node is
an immediate child of this element.
If the given node is not an immediate child of this element
then the Node.detach()
method should be used instead.public boolean remove(Namespace namespace)
Element
Namespace
if the node is
an immediate child of this element.
If the given node is not an immediate child of this element
then the Node.detach()
method should be used instead.public boolean remove(ProcessingInstruction pi)
Branch
ProcessingInstruction
if the node is
an immediate child of this branch.
If the given node is not an immediate child of this branch
then the Node.detach()
method should be used instead.remove
in interface Branch
remove
in class AbstractBranch
pi
- is the processing instruction to be removedpublic boolean remove(Text text)
Element
Text
if the node is
an immediate child of this element.
If the given node is not an immediate child of this element
then the Node.detach()
method should be used instead.public boolean hasMixedContent()
Element
Returns true if this Element
has mixed content.
Mixed content means that an element contains both textual data and
child elements.
hasMixedContent
in interface Element
public boolean isTextOnly()
Element
Returns true if this Element
has text only content.
isTextOnly
in interface Element
public void setText(String text)
Node
Sets the text data of this node or this method will
throw an UnsupportedOperationException
if it is
read-only.
setText
in interface Node
setText
in class AbstractNode
text
- is the new textual value of this nodepublic String getStringValue()
Node
getStringValue
in interface Element
getStringValue
in interface Node
getStringValue
in class AbstractNode
public void normalize()
Text
nodes in the full depth of the sub-tree
underneath this Node
, including attribute nodes, into a
"normal" form where only structure (e.g., elements, comments,
processing instructions, CDATA sections, and entity references)
separates Text
nodes, i.e., there are neither adjacent
Text
nodes nor empty Text
nodes. This can
be used to ensure that the DOM view of a document is the same as if
it were saved and re-loaded, and is useful when operations (such as
XPointer lookups) that depend on a particular document tree
structure are to be used.In cases where the document contains
CDATASections
, the normalize operation alone may not be
sufficient, since XPointers do not differentiate between
Text
nodes and CDATASection
nodes.public String elementText(String name)
elementText
in interface Element
public String elementText(QName qName)
elementText
in interface Element
public String elementTextTrim(String name)
elementTextTrim
in interface Element
public String elementTextTrim(QName qName)
elementTextTrim
in interface Element
public void appendAttributes(Element element)
Element
Collection.addAll(java.util.Collection)
method.appendAttributes
in interface Element
element
- is the element whose attributes will be added to me.public Element createCopy()
This returns a deep clone of this element. The new element is detached from its parent, and getParent() on the clone will return null.
createCopy
in interface Element
public Element createCopy(String name)
Element
Creates a deep copy of this element with the given local name The new element is detached from its parent, and getParent() on the clone will return null.
createCopy
in interface Element
public Element createCopy(QName qName)
Element
Creates a deep copy of this element with the given fully qualified name. The new element is detached from its parent, and getParent() on the clone will return null.
createCopy
in interface Element
public QName getQName(String qualifiedName)
Element
Returns the QName
for the given qualified name, using
the namespace URI in scope for the given prefix of the qualified name
or the default namespace if the qualified name has no prefix.
public Namespace getNamespaceForPrefix(String prefix)
Element
Returns the Namespace
which is mapped to the given
prefix or null if it could not be found.
getNamespaceForPrefix
in interface Element
Namespace
associated with the given prefixpublic Namespace getNamespaceForURI(String uri)
Element
Returns the Namespace
which is mapped to the given
URI or null if it could not be found.
getNamespaceForURI
in interface Element
Namespace
associated with the given URIpublic List declaredNamespaces()
Element
Returns all the namespaces declared by this element. If no namespaces are declared for this element then an empty list will be returned. The list is backed by the element such that changes to the list will be reflected in the element though the reverse is not the case.
declaredNamespaces
in interface Element
public List additionalNamespaces()
Element
Returns any additional namespaces declarations for this element
other than namespace returned via the Element.getNamespace()
method.
If no additional namespace declarations are present for this
element then an empty list will be returned.
The list is backed by the element such that changes to the list will
be reflected in the element though the reverse is not the case.
additionalNamespaces
in interface Element
public List additionalNamespaces(String defaultNamespaceURI)
public void ensureAttributesCapacity(int minCapacity)
protected Element createElement(String name)
protected Element createElement(QName qName)
protected void addNode(Node node)
addNode
in class AbstractBranch
protected void addNewNode(Node node)
protected boolean removeNode(Node node)
removeNode
in class AbstractBranch
protected void childAdded(Node node)
childAdded
in class AbstractBranch
protected void childRemoved(Node node)
AbstractBranch
childRemoved
in class AbstractBranch
protected abstract List attributeList()
protected abstract List attributeList(int attributeCount)
protected DocumentFactory getDocumentFactory()
getDocumentFactory
in class AbstractNode
protected List createAttributeList()
protected List createAttributeList(int size)
protected Iterator createSingleIterator(Object result)
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses