public abstract class AbstractDocument extends AbstractBranch implements Document
 AbstractDocument is an abstract base class for tree
 implementors to use for implementation inheritence.
 
| Modifier and Type | Field and Description | 
|---|---|
protected java.lang.String | 
encoding
The encoding of this document as stated in the XML declaration 
 | 
DEFAULT_CONTENT_LIST_SIZENODE_TYPE_NAMESANY_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 | 
|---|
AbstractDocument()  | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
accept(Visitor visitor)
accept method is the Visitor Pattern
 method. | 
void | 
add(Element element)
Adds the given  
Element to this branch. | 
Document | 
addComment(java.lang.String comment)
Adds a new  
Comment node with the given text to this
 branch. | 
Element | 
addElement(QName qName)
Adds a new  
Element node with the given QNameto
 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. | 
Document | 
addProcessingInstruction(java.lang.String target,
                        java.util.Map<java.lang.String,java.lang.String> data)
Adds a processing instruction for the given target 
 | 
Document | 
addProcessingInstruction(java.lang.String target,
                        java.lang.String data)
Adds a processing instruction for the given target 
 | 
java.lang.String | 
asXML()
asXML returns the textual XML representation of this node. | 
Node | 
asXPathResult(Element parent)
asXPathResult returns a version of this node which is
 capable of being an XPath result. | 
Document | 
getDocument()
getDocument returns the Document that this
 Node is part of if this node supports the parent
 relationship. | 
short | 
getNodeType()
Returns the code according to the type of node. 
 | 
java.lang.String | 
getPath(Element context)
Returns the relative XPath expression which will return a node set
 containing the given node such as a/b/@c. 
 | 
java.lang.String | 
getStringValue()
Returns the XPath string-value of this node. 
 | 
java.lang.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. 
 | 
java.lang.String | 
getXMLEncoding()
Return the encoding of this document, as part of the XML declaration This
 is  
null when unspecified or when it is not known (such as
 when the Document was created in memory) or when the implementation does
 not support this operation. | 
protected void | 
checkAddElementAllowed(Element element)  | 
protected 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 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. 
 | 
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. | 
boolean | 
remove(Element element)
Removes the given  
Element if the node is an immediate
 child of this branch. | 
protected abstract void | 
rootElementAdded(Element rootElement)
Called to set the root element variable 
 | 
void | 
setRootElement(Element rootElement)
Sets the root element for this document 
 | 
void | 
setXMLEncoding(java.lang.String enc)
Sets the encoding of this document as it will appear in the XML
 declaration part of the document. 
 | 
java.lang.String | 
toString()  | 
void | 
write(java.io.Writer out)
write writes this node as the default XML notation for
 this node. | 
add, add, add, addElement, addNode, addNode, appendContent, content, contentList, contentRemoved, createContentList, createContentList, createEmptyList, createResultList, createSingleResultList, elementByID, elementID, getContentAsStringValue, getContentAsText, getText, getTextTrim, hasContent, indexOf, invalidNodeTypeAddException, isReadOnly, node, nodeCount, nodeIterator, remove, remove, remove, removeNode, setProcessingInstructionsclone, createPattern, createXPath, createXPathFilter, createXPathResult, detach, getDocumentFactory, getName, getNodeTypeName, getParent, getPath, getUniquePath, matches, numberValueOf, selectNodes, selectNodes, selectNodes, selectObject, selectSingleNode, setDocument, setName, setParent, setText, supportsParent, valueOfequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddDocType, getDocType, getEntityResolver, getRootElement, setDocType, setEntityResolveradd, add, add, appendContent, clearContent, content, elementByID, indexOf, node, nodeCount, nodeIterator, processingInstruction, processingInstructions, processingInstructions, remove, remove, remove, removeProcessingInstruction, setContent, setProcessingInstructionsclone, createXPath, detach, getName, getNodeTypeName, getParent, getPath, getText, getUniquePath, hasContent, isReadOnly, matches, numberValueOf, selectNodes, selectNodes, selectNodes, selectObject, selectSingleNode, setDocument, setName, setParent, setText, supportsParent, valueOfprotected java.lang.String encoding
public short getNodeType()
NodegetNodeType in interface NodegetNodeType in class AbstractNodepublic java.lang.String getPath(Element context)
NodegetPath in interface Nodecontext - 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 java.lang.String getUniquePath(Element context)
NodeReturns 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 Nodecontext - 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 Document getDocument()
Node
 getDocument returns the Document that this
 Node is part of if this node supports the parent
 relationship.
 
 This method is an optional feature and may not be supported for all
 Node implementations.
 
getDocument in interface NodegetDocument in class AbstractNodeDocumentpublic java.lang.String getXMLEncoding()
Documentnull when unspecified or when it is not known (such as
 when the Document was created in memory) or when the implementation does
 not support this operation.
 
 The way this encoding is retrieved also depends on the way the XML source
 is parsed. For instance, if the SAXReader is used and if the underlying
 XMLReader implementation support the
 org.xml.sax.ext.Locator2 interface, the result returned by
 this method is specified by the getEncoding() method of
 that interface.getXMLEncoding in interface Documentnull if unknown.public java.lang.String getStringValue()
NodegetStringValue in interface NodegetStringValue in class AbstractNodepublic java.lang.String asXML()
Node
 asXML returns the textual XML representation of this node.
 
public void write(java.io.Writer out)
           throws java.io.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 Nodewrite in class AbstractNodeout - is the Writer to output the XML tojava.io.IOException - DOCUMENT ME!public void accept(Visitor visitor)
 accept method is the Visitor Pattern
 method.
 
public java.lang.String toString()
toString in class java.lang.Objectpublic void normalize()
BranchText 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 Document addComment(java.lang.String comment)
DocumentComment node with the given text to this
 branch.addComment in interface Documentcomment - is the text for the Comment node.Document instance.public Document addProcessingInstruction(java.lang.String target, java.lang.String data)
DocumentaddProcessingInstruction in interface Documenttarget - is the target of the processing instructiondata - is the textual data (key/value pairs) of the processing
            instructionDocument instance.public Document addProcessingInstruction(java.lang.String target, java.util.Map<java.lang.String,java.lang.String> data)
DocumentaddProcessingInstruction in interface Documenttarget - is the target of the processing instructiondata - is a Map of the key / value pairs of the processing
            instructionDocument instance.public 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 BranchaddElement in class AbstractBranchname - 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 BranchaddElement in class AbstractBranchqualifiedName - is the fully qualified name of the ElementnamespaceURI - is the URI of the namespace to useElement node.public Element addElement(QName qName)
BranchElement node with the given QNameto
 this branch and returns a reference to the new node.addElement in interface BranchaddElement in class AbstractBranchqName - is the qualified name for the Element node.Element node.public void setRootElement(Element rootElement)
DocumentsetRootElement in interface DocumentrootElement - the new root element for this documentpublic 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 Branchadd in class AbstractBranchelement - is the element to be addedpublic 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 Branchremove in class AbstractBranchelement - is the element to be removedpublic Node asXPathResult(Element parent)
Node
 asXPathResult returns a version of this node which is
 capable of being an XPath result. The result of an XPath expression
 should always support the parent relationship, whether the original XML
 tree was singly or doubly linked. If the node does not support the parent
 relationship then a new node will be created which is linked to its
 parent and returned.
 
asXPathResult in interface NodeasXPathResult in class AbstractNodeparent - DOCUMENT ME!Node which supports the parent relationshipprotected void childAdded(Node node)
AbstractBranchchildAdded in class AbstractBranchnode - DOCUMENT ME!protected void childRemoved(Node node)
AbstractBranchchildRemoved in class AbstractBranchnode - DOCUMENT ME!protected void checkAddElementAllowed(Element element)
protected abstract void rootElementAdded(Element rootElement)
rootElement - DOCUMENT ME!public void setXMLEncoding(java.lang.String enc)
DocumentsetXMLEncoding in interface Documentenc - the encoding of the document