|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.dom4j.tree.AbstractNode
org.dom4j.tree.AbstractBranch
AbstractBranch is an abstract base class for
tree implementors to use for implementation inheritence.
| Field Summary | |
protected static int |
DEFAULT_CONTENT_LIST_SIZE
|
protected static OutputFormat |
outputFormat
The output format used by default |
| Fields inherited from class org.dom4j.tree.AbstractNode |
NODE_TYPE_NAMES |
| Fields inherited from interface org.dom4j.Node |
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 Summary | |
AbstractBranch()
|
|
| Method Summary | |
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(java.lang.String name)
Adds a new Element node with the given name to this branch
and returns a reference to the new node. |
Element |
addElement(java.lang.String qualifiedName,
java.lang.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(java.lang.String name,
java.lang.String prefix,
java.lang.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. |
java.util.List |
content()
Returns the content nodes of this branch as a backed List
so that the content of this branch may be modified directly using
the List interface. |
protected abstract java.util.List |
contentList()
|
protected void |
contentRemoved()
Called when the given List content has been removed so each node should have its parent and document relationships cleared |
protected java.util.List |
createContentList()
A Factory Method pattern which creates a List implementation used to store content |
protected java.util.List |
createContentList(int size)
A Factory Method pattern which creates a List implementation used to store content |
protected java.util.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 java.util.List |
createSingleResultList(java.lang.Object result)
A Factory Method pattern which creates a BackedList implementation which contains a single result |
Element |
elementByID(java.lang.String elementID)
Returns the element of the given ID attribute value. |
protected java.lang.String |
elementID(Element element)
|
protected java.lang.String |
getContentAsStringValue(java.lang.Object content)
|
protected java.lang.String |
getContentAsText(java.lang.Object content)
|
java.lang.String |
getText()
Returns the text of this node. |
java.lang.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. |
java.util.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(java.util.List listOfPIs)
Sets all the processing instructions for this branch |
| Methods inherited from class org.dom4j.tree.AbstractNode |
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 |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.dom4j.Branch |
clearContent, normalize, processingInstruction, processingInstructions, processingInstructions, removeProcessingInstruction, setContent |
| Methods inherited from interface org.dom4j.Node |
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 |
| Field Detail |
protected static final OutputFormat outputFormat
protected static final int DEFAULT_CONTENT_LIST_SIZE
| Constructor Detail |
public AbstractBranch()
| Method Detail |
public boolean isReadOnly()
NodeisReadOnly 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 NodeisReadOnly in class AbstractNodepublic boolean hasContent()
NodehasContent 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 NodehasContent in class AbstractNodepublic java.util.List content()
BranchReturns the content nodes of this branch as a backed List
so that the content of this branch may be modified directly using
the List interface.
The List is backed by the Branch so that
changes to the list are reflected in the branch and vice versa.
content in interface BranchListpublic java.lang.String getText()
NodeReturns the text of this node.
getText in interface NodegetText in class AbstractNodeprotected java.lang.String getContentAsText(java.lang.Object content)
protected java.lang.String getContentAsStringValue(java.lang.Object content)
public java.lang.String getTextTrim()
public void setProcessingInstructions(java.util.List listOfPIs)
Branch
setProcessingInstructions in interface Branchpublic Element addElement(java.lang.String name)
BranchElement node with the given name to this branch
and returns a reference to the new node.
addElement in interface Branchname - is the name for the Element node.
Element node.
public Element addElement(java.lang.String qualifiedName,
java.lang.String namespaceURI)
BranchElement node with the given qualified name
and namespace URI to this branch and returns a reference to the new node.
addElement in interface BranchqualifiedName - is the fully qualified name of the ElementnamespaceURI - is the URI of the namespace to use
Element node.public Element addElement(QName qname)
BranchElement node with the given QName
to this branch and returns a reference to the new node.
addElement in interface Branchqname - is the qualified name for the Element node.
Element node.
public Element addElement(java.lang.String name,
java.lang.String prefix,
java.lang.String uri)
public void add(Node node)
BranchNode 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 Branchnode - is the given node to addpublic boolean remove(Node node)
BranchNode 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 Branchnode - is the given node to be removed
public void add(Comment comment)
BranchComment to this branch.
If the given node already has a parent defined then an
IllegalAddException will be thrown.
add in interface Branchcomment - is the comment to be addedpublic void add(Element element)
BranchElement to this branch.
If the given node already has a parent defined then an
IllegalAddException will be thrown.
add in interface Branchelement - is the element to be addedpublic void add(ProcessingInstruction pi)
BranchProcessingInstruction to this branch.
If the given node already has a parent defined then an
IllegalAddException will be thrown.
add in interface Branchpi - is the processing instruction to be addedpublic boolean remove(Comment comment)
BranchComment 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 Branchcomment - is the comment to be removed
public boolean remove(Element element)
BranchElement 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 Branchelement - is the element to be removed
public boolean remove(ProcessingInstruction pi)
BranchProcessingInstruction 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 Branchpi - is the processing instruction to be removed
public Element elementByID(java.lang.String elementID)
Branch
elementByID in interface Branchpublic void appendContent(Branch branch)
BranchCollection.addAll(java.util.Collection)
method.
appendContent in interface Branchbranch - is the branch whose content will be added to me.public Node node(int index)
BranchNode at the specified index position.
node in interface Branchindex - the index of the node to return.
Node at the specified position.public int nodeCount()
BranchNode instances that this branch
contains.
nodeCount in interface Branchpublic int indexOf(Node node)
Branch
indexOf in interface Branchnode - the content child node to find.
public java.util.Iterator nodeIterator()
Branch
nodeIterator in interface Branchprotected java.lang.String elementID(Element element)
Elementprotected abstract java.util.List contentList()
protected java.util.List createContentList()
protected java.util.List createContentList(int size)
protected BackedList createResultList()
protected java.util.List createSingleResultList(java.lang.Object result)
protected java.util.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)
protected abstract void childRemoved(Node node)
protected void contentRemoved()
protected void invalidNodeTypeAddException(Node node)
IllegalAddException.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||