de.pdark.decentxml
Class Document

java.lang.Object
  extended by de.pdark.decentxml.NodeWithChildren
      extended by de.pdark.decentxml.Document
All Implemented Interfaces:
Node, Parent

public class Document
extends NodeWithChildren
implements Parent

This class represents an XML document.

If you add a ProcessingInstruction as the first node of the document, it will be converted into an XMLDeclaration.

Note: The automatic creation of XMLDeclaration is not perfect; if you manipulate the list of nodes yourself (for example, via getNodes().add()), then you're on your own.

Author:
DIGULAA

Constructor Summary
Document()
           
Document(Node... nodes)
           
 
Method Summary
 Document addNode(int index, Node node)
           
 Document addNode(Node node)
           
 Document addNodes(java.util.Collection<? extends Node> nodes)
           
 Document addNodes(int index, java.util.Collection<? extends Node> nodes)
           
 Document addNodes(int index, Node... nodes)
           
 Document addNodes(Node... nodes)
           
protected  void clearXMLDeclaration()
           
 Document copy()
          Simulate clone()
 Document copy(Node orig)
          Copy all data from orig into this
 Document createClone()
          Simulate clone()
protected  XMLDeclaration createXMLDeclaration()
           
 Element getChild(java.lang.String path)
          Find a child element (not a node!) by path
 Element getChild(java.lang.String path, Namespace ns)
           
 DocType getDocType()
           
 java.lang.String getEncoding()
           
 Namespace getNamespace(java.lang.String prefix)
           
 Namespaces getNamespaces()
           
 Element getRootElement()
           
 XMLTokenizer.Type getType()
          Get the node type
 java.lang.String getVersion()
           
 XMLDeclaration getXmlDeclaration()
           
 boolean isStandalone()
           
 void parseXMLDeclaration()
          Parse a possible XML declaration and fill the internal fields with the data.
 Node removeNode(int index)
          Remove a node from the list
 boolean removeNode(Node n)
          Remove a node from the list
 void setDocType(DocType docType)
           
 Document setEncoding(java.lang.String encoding)
           
 void setNamespaces(Namespaces namespaces)
           
 Document setRootNode(Element rootNode)
           
 void setStandalone(boolean standalone)
           
 Document setVersion(java.lang.String version)
           
 void setXmlDeclaration(XMLDeclaration xmlDeclaration)
           
 Document toXML(XMLWriter writer)
          Fast way to convert many nodes to XML
 
Methods inherited from class de.pdark.decentxml.NodeWithChildren
clearNodes, getNode, getNodes, getNodes, hasNodes, nodeCount, nodeIndexOf, toString, toXML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.pdark.decentxml.Parent
clearNodes, getNode, getNodes, hasNodes, nodeCount, nodeIndexOf
 
Methods inherited from interface de.pdark.decentxml.Node
toXML
 

Constructor Detail

Document

public Document()

Document

public Document(Node... nodes)
Method Detail

addNode

public Document addNode(Node node)
Specified by:
addNode in interface Parent
Overrides:
addNode in class NodeWithChildren

addNode

public Document addNode(int index,
                        Node node)
Specified by:
addNode in interface Parent
Overrides:
addNode in class NodeWithChildren

addNodes

public Document addNodes(java.util.Collection<? extends Node> nodes)
Specified by:
addNodes in interface Parent
Overrides:
addNodes in class NodeWithChildren

addNodes

public Document addNodes(int index,
                         java.util.Collection<? extends Node> nodes)
Specified by:
addNodes in interface Parent
Overrides:
addNodes in class NodeWithChildren

addNodes

public Document addNodes(Node... nodes)
Specified by:
addNodes in interface Parent
Overrides:
addNodes in class NodeWithChildren

addNodes

public Document addNodes(int index,
                         Node... nodes)
Specified by:
addNodes in interface Parent
Overrides:
addNodes in class NodeWithChildren

removeNode

public Node removeNode(int index)
Description copied from interface: Parent
Remove a node from the list

Specified by:
removeNode in interface Parent
Overrides:
removeNode in class NodeWithChildren
Returns:
The removed node.

removeNode

public boolean removeNode(Node n)
Description copied from interface: Parent
Remove a node from the list

Specified by:
removeNode in interface Parent
Overrides:
removeNode in class NodeWithChildren
Returns:
true, if the node is in the list

getChild

public Element getChild(java.lang.String path)
Description copied from interface: Parent
Find a child element (not a node!) by path

Specified by:
getChild in interface Parent

getChild

public Element getChild(java.lang.String path,
                        Namespace ns)

getType

public XMLTokenizer.Type getType()
Description copied from interface: Node
Get the node type

Specified by:
getType in interface Node

getRootElement

public Element getRootElement()

setRootNode

public Document setRootNode(Element rootNode)

getXmlDeclaration

public XMLDeclaration getXmlDeclaration()

setXmlDeclaration

public void setXmlDeclaration(XMLDeclaration xmlDeclaration)

getVersion

public java.lang.String getVersion()

setVersion

public Document setVersion(java.lang.String version)

createXMLDeclaration

protected XMLDeclaration createXMLDeclaration()

getEncoding

public java.lang.String getEncoding()

setEncoding

public Document setEncoding(java.lang.String encoding)

isStandalone

public boolean isStandalone()

setStandalone

public void setStandalone(boolean standalone)

toXML

public Document toXML(XMLWriter writer)
               throws java.io.IOException
Description copied from interface: Node
Fast way to convert many nodes to XML

Specified by:
toXML in interface Node
Overrides:
toXML in class NodeWithChildren
Throws:
java.io.IOException

parseXMLDeclaration

public void parseXMLDeclaration()
Parse a possible XML declaration and fill the internal fields with the data.


clearXMLDeclaration

protected void clearXMLDeclaration()

getDocType

public DocType getDocType()

setDocType

public void setDocType(DocType docType)

getNamespaces

public Namespaces getNamespaces()

setNamespaces

public void setNamespaces(Namespaces namespaces)

getNamespace

public Namespace getNamespace(java.lang.String prefix)

createClone

public Document createClone()
Description copied from interface: Node
Simulate clone()

Specified by:
createClone in interface Node

copy

public Document copy(Node orig)
Description copied from interface: Node
Copy all data from orig into this

Specified by:
copy in interface Node
Overrides:
copy in class NodeWithChildren

copy

public Document copy()
Description copied from interface: Node
Simulate clone()

Specified by:
copy in interface Node
Overrides:
copy in class NodeWithChildren


Copyright © 2008-2011. All Rights Reserved.