Package de.pdark.decentxml
Class Document
- java.lang.Object
-
- de.pdark.decentxml.NodeWithChildren
-
- de.pdark.decentxml.Document
-
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 anXMLDeclaration
.Note: The automatic creation of
XMLDeclaration
is not perfect; if you manipulate the list of nodes yourself (for example, viagetNodes().add()
), then you're on your own.- Author:
- DIGULAA
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Document
addNode(int index, Node node)
Document
addNode(Node node)
Document
addNodes(int index, Node... nodes)
Document
addNodes(int index, java.util.Collection<? extends Node> nodes)
Document
addNodes(Node... nodes)
Document
addNodes(java.util.Collection<? extends Node> nodes)
protected void
clearXMLDeclaration()
Document
copy()
Simulate clone()Document
copy(Node orig)
Copy all data fromorig
intothis
Document
createClone()
Simulate clone()protected XMLDeclaration
createXMLDeclaration()
Element
getChild(java.lang.String path)
Find a child element (not a node!) by pathElement
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 typejava.lang.String
getVersion()
XMLDeclaration
getXmlDeclaration()
boolean
isStandalone()
TreeIterator
iterator()
void
parseXMLDeclaration()
Parse a possible XML declaration and fill the internal fields with the data.Node
removeNode(int index)
Remove a node from the listboolean
removeNode(Node n)
Remove a node from the listvoid
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
-
-
-
-
Constructor Detail
-
Document
public Document()
-
Document
public Document(Node... nodes)
-
-
Method Detail
-
addNode
public Document addNode(Node node)
- Specified by:
addNode
in interfaceParent
- Overrides:
addNode
in classNodeWithChildren
-
addNode
public Document addNode(int index, Node node)
- Specified by:
addNode
in interfaceParent
- Overrides:
addNode
in classNodeWithChildren
-
addNodes
public Document addNodes(java.util.Collection<? extends Node> nodes)
- Specified by:
addNodes
in interfaceParent
- Overrides:
addNodes
in classNodeWithChildren
-
addNodes
public Document addNodes(int index, java.util.Collection<? extends Node> nodes)
- Specified by:
addNodes
in interfaceParent
- Overrides:
addNodes
in classNodeWithChildren
-
addNodes
public Document addNodes(Node... nodes)
- Specified by:
addNodes
in interfaceParent
- Overrides:
addNodes
in classNodeWithChildren
-
addNodes
public Document addNodes(int index, Node... nodes)
- Specified by:
addNodes
in interfaceParent
- Overrides:
addNodes
in classNodeWithChildren
-
removeNode
public Node removeNode(int index)
Description copied from interface:Parent
Remove a node from the list- Specified by:
removeNode
in interfaceParent
- Overrides:
removeNode
in classNodeWithChildren
- 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 interfaceParent
- Overrides:
removeNode
in classNodeWithChildren
- 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
-
getType
public XMLTokenizer.Type getType()
Description copied from interface:Node
Get the node type
-
getRootElement
public Element getRootElement()
-
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 interfaceNode
- Overrides:
toXML
in classNodeWithChildren
- 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 interfaceNode
-
copy
public Document copy(Node orig)
Description copied from interface:Node
Copy all data fromorig
intothis
- Specified by:
copy
in interfaceNode
- Overrides:
copy
in classNodeWithChildren
-
copy
public Document copy()
Description copied from interface:Node
Simulate clone()- Specified by:
copy
in interfaceNode
- Overrides:
copy
in classNodeWithChildren
-
iterator
public TreeIterator iterator()
-
-