Class AbstractBranch
java.lang.Object
org.dom4j.tree.AbstractNode
org.dom4j.tree.AbstractBranch
- All Implemented Interfaces:
Serializable, Cloneable, Branch, Node
- Direct Known Subclasses:
AbstractDocument, AbstractElement
AbstractBranch is an abstract base class for tree implementors
to use for implementation inheritence.- Version:
- $Revision: 1.44 $
- Author:
- James Strachan
- See Also:
-
Field Summary
FieldsFields inherited from class AbstractNode
NODE_TYPE_NAMESFields inherited from interface 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the givenCommentto this branch.voidAdds the givenElementto this branch.voidAdds the givenNodeor throwsIllegalAddExceptionif the given node is not of a valid type.voidAdds the givenProcessingInstructionto this branch.addElement(String name) Adds a newElementnode with the given name to this branch and returns a reference to the new node.addElement(String qualifiedName, String namespaceURI) Adds a newElementnode with the given qualified name and namespace URI to this branch and returns a reference to the new node.addElement(String name, String prefix, String uri) addElement(QName qname) Adds a newElementnode with the givenQNameto this branch and returns a reference to the new node.protected abstract voidprotected abstract voidvoidappendContent(Branch branch) Appends the content of the given branch to this branch instance.protected abstract voidchildAdded(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 voidchildRemoved(Node node) Called when a child node has been removed to allow any parent relationships to be deleted or events to be fired.content()DOCUMENT ME!protected voidCalled when the given List content has been removed so each node should have its parent and document relationships clearedA Factory Method pattern which creates a List implementation used to store contentcreateContentList(int size) A Factory Method pattern which creates a List implementation used to store contentA Factory Method pattern which creates an empty a BackedList implementationprotected <T extends Node>
BackedList<T> A Factory Method pattern which creates a BackedList implementation used to store results of a filtered content query.createSingleResultList(T result) A Factory Method pattern which creates a BackedList implementation which contains a single resultelementByID(String elementID) Returns the element of the given ID attribute value.protected StringDOCUMENT ME!protected StringgetContentAsStringValue(Object content) DOCUMENT ME!protected StringgetContentAsText(Object content) DOCUMENT ME!getText()Returns the text of this node.booleanhasContentreturns 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.intReturns 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 voidCalled when an invalid node has been added.booleanisReadOnlyreturns true if this node is read only and cannot be modified.node(int index) Returns theNodeat the specified index position.intReturns the number ofNodeinstances that this branch contains.Returns an iterator through the content nodes of this branchbooleanRemoves the givenCommentif the node is an immediate child of this branch.booleanRemoves the givenElementif the node is an immediate child of this branch.booleanRemoves the givenNodeif the node is an immediate child of this branch.booleanRemoves the givenProcessingInstructionif the node is an immediate child of this branch.protected abstract booleanremoveNode(Node node) voidsetProcessingInstructions(List<ProcessingInstruction> listOfPIs) Sets all the processing instructions for this branchMethods inherited from class 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, writeMethods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Branch
clearContent, normalize, processingInstruction, processingInstructions, processingInstructions, removeProcessingInstruction, setContentMethods inherited from interface 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 Details
-
DEFAULT_CONTENT_LIST_SIZE
protected static final int DEFAULT_CONTENT_LIST_SIZE- See Also:
-
-
Constructor Details
-
AbstractBranch
public AbstractBranch()
-
-
Method Details
-
isReadOnly
public boolean isReadOnly()Description copied from interface:NodeisReadOnlyreturns true if this node is read only and cannot be modified. Any attempt to modify a read-onlyNodewill result in anUnsupportedOperationExceptionbeing thrown.- Specified by:
isReadOnlyin interfaceNode- Overrides:
isReadOnlyin classAbstractNode- Returns:
- true if this
Nodeis read only and cannot be modified otherwise false.
-
hasContent
public boolean hasContent()Description copied from interface:NodehasContentreturns 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.- Specified by:
hasContentin interfaceNode- Overrides:
hasContentin classAbstractNode- Returns:
- true if this
Nodeis a Branch with a nodeCount() of one or more.
-
content
-
getText
-
getContentAsText
-
getContentAsStringValue
-
getTextTrim
-
setProcessingInstructions
Description copied from interface:BranchSets all the processing instructions for this branch- Specified by:
setProcessingInstructionsin interfaceBranch- Parameters:
listOfPIs- DOCUMENT ME!
-
addElement
Description copied from interface:BranchAdds a newElementnode with the given name to this branch and returns a reference to the new node.- Specified by:
addElementin interfaceBranch- Parameters:
name- is the name for theElementnode.- Returns:
- the newly added
Elementnode.
-
addElement
Description copied from interface:BranchAdds a newElementnode with the given qualified name and namespace URI to this branch and returns a reference to the new node.- Specified by:
addElementin interfaceBranch- Parameters:
qualifiedName- is the fully qualified name of the ElementnamespaceURI- is the URI of the namespace to use- Returns:
- the newly added
Elementnode.
-
addElement
Description copied from interface:BranchAdds a newElementnode with the givenQNameto this branch and returns a reference to the new node.- Specified by:
addElementin interfaceBranch- Parameters:
qname- is the qualified name for theElementnode.- Returns:
- the newly added
Elementnode.
-
addElement
-
add
Description copied from interface:BranchAdds the givenNodeor throwsIllegalAddExceptionif 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). -
remove
Description copied from interface:BranchRemoves the givenNodeif the node is an immediate child of this branch. If the given node is not an immediate child of this branch then theNode.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). -
add
-
add
-
add
Description copied from interface:BranchAdds the givenProcessingInstructionto this branch. If the given node already has a parent defined then anIllegalAddExceptionwill be thrown. -
remove
Description copied from interface:BranchRemoves the givenCommentif the node is an immediate child of this branch. If the given node is not an immediate child of this branch then theNode.detach()method should be used instead. -
remove
Description copied from interface:BranchRemoves the givenElementif the node is an immediate child of this branch. If the given node is not an immediate child of this branch then theNode.detach()method should be used instead. -
remove
Description copied from interface:BranchRemoves the givenProcessingInstructionif the node is an immediate child of this branch. If the given node is not an immediate child of this branch then theNode.detach()method should be used instead. -
elementByID
Description copied from interface:BranchReturns the element of the given ID attribute value. If this tree is capable of understanding which attribute value should be used for the ID then it should be used, otherwise this method should return null.- Specified by:
elementByIDin interfaceBranch- Parameters:
elementID- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
appendContent
Description copied from interface:BranchAppends the content of the given branch to this branch instance. This method behaves like theCollection.addAll(java.util.Collection)method.- Specified by:
appendContentin interfaceBranch- Parameters:
branch- is the branch whose content will be added to me.
-
node
-
nodeCount
-
indexOf
Description copied from interface:BranchReturns 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. -
nodeIterator
Description copied from interface:BranchReturns an iterator through the content nodes of this branch- Specified by:
nodeIteratorin interfaceBranch- Returns:
- an iterator through the content nodes of this branch
-
elementID
-
contentList
-
createContentList
-
createContentList
-
createResultList
A Factory Method pattern which creates a BackedList implementation used to store results of a filtered content query.- Type Parameters:
T- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
createSingleResultList
-
createEmptyList
-
addNode
-
addNode
-
removeNode
-
childAdded
Called when a new child node has been added to me to allow any parent relationships to be created or events to be fired.- Parameters:
node- DOCUMENT ME!
-
childRemoved
Called when a child node has been removed to allow any parent relationships to be deleted or events to be fired.- Parameters:
node- DOCUMENT ME!
-
contentRemoved
protected void contentRemoved()Called when the given List content has been removed so each node should have its parent and document relationships cleared -
invalidNodeTypeAddException
Called when an invalid node has been added. Throws anIllegalAddException.- Parameters:
node- DOCUMENT ME!- Throws:
IllegalAddException- DOCUMENT ME!
-