public abstract class AbstractBranch extends AbstractNode implements Branch
AbstractBranch
is an abstract base class for tree implementors
to use for implementation inheritence.
Modifier and Type | Field and Description |
---|---|
protected static int |
DEFAULT_CONTENT_LIST_SIZE |
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 |
---|
AbstractBranch() |
Modifier and Type | Method and Description |
---|---|
void |
add(Comment comment)
Adds the given
Comment to this branch. |
void |
add(Element element)
Adds the given
Element to this branch. |
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. |
Element |
addElement(QName qname)
Adds a new
Element node with the given QName to
this branch and returns a reference to the new node. |
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 |
addElement(String qualifiedName,
String namespaceURI)
Adds a new
Element node with the given qualified name and
namespace URI to this branch and returns a reference to the new node. |
Element |
addElement(String name,
String prefix,
String uri) |
protected abstract void |
addNode(int index,
Node node) |
protected abstract void |
addNode(Node node) |
void |
appendContent(Branch branch)
Appends the content of the given branch to this branch instance.
|
protected abstract void |
childAdded(Node node)
Called when a new child node has been added to me to allow any parent
relationships to be created or events to be fired.
|
protected abstract 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.
|
List |
content()
|
protected abstract List |
contentList()
DOCUMENT ME!
|
protected void |
contentRemoved()
Called when the given List content has been removed so each node should
have its parent and document relationships cleared
|
protected List |
createContentList()
A Factory Method pattern which creates a List implementation used to
store content
|
protected List |
createContentList(int size)
A Factory Method pattern which creates a List implementation used to
store content
|
protected List |
createEmptyList()
A Factory Method pattern which creates an empty a BackedList
implementation
|
protected BackedList |
createResultList()
A Factory Method pattern which creates a BackedList implementation used
to store results of a filtered content query.
|
protected List |
createSingleResultList(Object result)
A Factory Method pattern which creates a BackedList implementation which
contains a single result
|
Element |
elementByID(String elementID)
Returns the element of the given ID attribute value.
|
protected String |
elementID(Element element)
DOCUMENT ME!
|
protected String |
getContentAsStringValue(Object content)
DOCUMENT ME!
|
protected String |
getContentAsText(Object content)
DOCUMENT ME!
|
String |
getText()
Returns the text of this node.
|
String |
getTextTrim() |
boolean |
hasContent()
hasContent returns true if this node is a Branch (either
an Element or a Document) and it contains at least one content node such
as a child Element or Text node. |
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.
|
protected void |
invalidNodeTypeAddException(Node node)
Called when an invalid node has been added.
|
boolean |
isReadOnly()
isReadOnly returns true if this node is read only and
cannot be modified. |
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
|
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(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. |
protected abstract boolean |
removeNode(Node node) |
void |
setProcessingInstructions(List listOfPIs)
Sets all the processing instructions for this branch
|
asXPathResult, clone, createPattern, createXPath, createXPathFilter, createXPathResult, detach, getDocument, getDocumentFactory, getName, getNodeType, getNodeTypeName, getParent, getPath, getStringValue, getUniquePath, matches, numberValueOf, selectNodes, selectNodes, selectNodes, selectObject, selectSingleNode, setDocument, setName, setParent, setText, supportsParent, valueOf, write
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
clearContent, normalize, processingInstruction, processingInstructions, processingInstructions, removeProcessingInstruction, setContent
accept, asXML, asXPathResult, clone, createXPath, detach, getDocument, getName, getNodeType, getNodeTypeName, getParent, getPath, getPath, getStringValue, getUniquePath, getUniquePath, matches, numberValueOf, selectNodes, selectNodes, selectNodes, selectObject, selectSingleNode, setDocument, setName, setParent, setText, supportsParent, valueOf, write
protected static final int DEFAULT_CONTENT_LIST_SIZE
public boolean isReadOnly()
Node
isReadOnly
returns true if this node is read only and
cannot be modified. Any attempt to modify a read-only Node
will result in an UnsupportedOperationException
being
thrown.
isReadOnly
in interface Node
isReadOnly
in class AbstractNode
Node
is read only and cannot be
modified otherwise false.public boolean hasContent()
Node
hasContent
returns true if this node is a Branch (either
an Element or a Document) and it contains at least one content node such
as a child Element or Text node.
hasContent
in interface Node
hasContent
in class AbstractNode
Node
is a Branch with a nodeCount()
of one or more.public String getText()
Node
Returns the text of this node.
getText
in interface Node
getText
in class AbstractNode
protected String getContentAsText(Object content)
content
- DOCUMENT ME!protected String getContentAsStringValue(Object content)
content
- DOCUMENT ME!public String getTextTrim()
public void setProcessingInstructions(List listOfPIs)
Branch
setProcessingInstructions
in interface Branch
listOfPIs
- DOCUMENT ME!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
name
- is the name for the Element
node.Element
node.public Element addElement(String qualifiedName, String namespaceURI)
Branch
Element
node with the given qualified name and
namespace URI to this branch and returns a reference to the new node.addElement
in interface Branch
qualifiedName
- is the fully qualified name of the ElementnamespaceURI
- is the URI of the namespace to useElement
node.public Element addElement(QName qname)
Branch
Element
node with the given QName
to
this branch and returns a reference to the new node.addElement
in interface Branch
qname
- is the qualified name for the Element
node.Element
node.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).public 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).public void add(Comment comment)
Branch
Comment
to this branch. If the given node
already has a parent defined then an IllegalAddException
will be thrown.public void add(Element element)
Branch
Element
to this branch. If the given node
already has a parent defined then an IllegalAddException
will be thrown.public void add(ProcessingInstruction pi)
Branch
ProcessingInstruction
to this branch. If
the given node already has a parent defined then an
IllegalAddException
will be thrown.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.public 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.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.public Element elementByID(String elementID)
Branch
elementByID
in interface Branch
elementID
- DOCUMENT ME!public void appendContent(Branch branch)
Branch
Collection.addAll(java.util.Collection)
method.appendContent
in interface Branch
branch
- is the branch whose content will be added to me.public Node node(int index)
Branch
Node
at the specified index position.public int nodeCount()
Branch
Node
instances that this branch
contains.public int indexOf(Node node)
Branch
public Iterator nodeIterator()
Branch
nodeIterator
in interface Branch
protected String elementID(Element element)
element
- DOCUMENT ME!Element
protected abstract List contentList()
protected List createContentList()
protected List createContentList(int size)
size
- DOCUMENT ME!protected BackedList createResultList()
protected List createSingleResultList(Object result)
result
- DOCUMENT ME!protected List createEmptyList()
protected abstract void addNode(Node node)
protected abstract void addNode(int index, Node node)
protected abstract boolean removeNode(Node node)
protected abstract void childAdded(Node node)
node
- DOCUMENT ME!protected abstract void childRemoved(Node node)
node
- DOCUMENT ME!protected void contentRemoved()
protected void invalidNodeTypeAddException(Node node)
IllegalAddException
.node
- DOCUMENT ME!IllegalAddException
- DOCUMENT ME!Copyright © 2012 JBoss by Red Hat. All Rights Reserved.