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
ProcessingInstructionas the first node of the document, it will be converted into anXMLDeclaration.Note: The automatic creation of
XMLDeclarationis 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 DocumentaddNode(int index, Node node)DocumentaddNode(Node node)DocumentaddNodes(int index, Node... nodes)DocumentaddNodes(int index, java.util.Collection<? extends Node> nodes)DocumentaddNodes(Node... nodes)DocumentaddNodes(java.util.Collection<? extends Node> nodes)protected voidclearXMLDeclaration()Documentcopy()Simulate clone()Documentcopy(Node orig)Copy all data fromorigintothisDocumentcreateClone()Simulate clone()protected XMLDeclarationcreateXMLDeclaration()ElementgetChild(java.lang.String path)Find a child element (not a node!) by pathElementgetChild(java.lang.String path, Namespace ns)DocTypegetDocType()java.lang.StringgetEncoding()NamespacegetNamespace(java.lang.String prefix)NamespacesgetNamespaces()ElementgetRootElement()XMLTokenizer.TypegetType()Get the node typejava.lang.StringgetVersion()XMLDeclarationgetXmlDeclaration()booleanisStandalone()TreeIteratoriterator()voidparseXMLDeclaration()Parse a possible XML declaration and fill the internal fields with the data.NoderemoveNode(int index)Remove a node from the listbooleanremoveNode(Node n)Remove a node from the listvoidsetDocType(DocType docType)DocumentsetEncoding(java.lang.String encoding)voidsetNamespaces(Namespaces namespaces)DocumentsetRootNode(Element rootNode)voidsetStandalone(boolean standalone)DocumentsetVersion(java.lang.String version)voidsetXmlDeclaration(XMLDeclaration xmlDeclaration)DocumenttoXML(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:
addNodein interfaceParent- Overrides:
addNodein classNodeWithChildren
-
addNode
public Document addNode(int index, Node node)
- Specified by:
addNodein interfaceParent- Overrides:
addNodein classNodeWithChildren
-
addNodes
public Document addNodes(java.util.Collection<? extends Node> nodes)
- Specified by:
addNodesin interfaceParent- Overrides:
addNodesin classNodeWithChildren
-
addNodes
public Document addNodes(int index, java.util.Collection<? extends Node> nodes)
- Specified by:
addNodesin interfaceParent- Overrides:
addNodesin classNodeWithChildren
-
addNodes
public Document addNodes(Node... nodes)
- Specified by:
addNodesin interfaceParent- Overrides:
addNodesin classNodeWithChildren
-
addNodes
public Document addNodes(int index, Node... nodes)
- Specified by:
addNodesin interfaceParent- Overrides:
addNodesin classNodeWithChildren
-
removeNode
public Node removeNode(int index)
Description copied from interface:ParentRemove a node from the list- Specified by:
removeNodein interfaceParent- Overrides:
removeNodein classNodeWithChildren- Returns:
- The removed node.
-
removeNode
public boolean removeNode(Node n)
Description copied from interface:ParentRemove a node from the list- Specified by:
removeNodein interfaceParent- Overrides:
removeNodein classNodeWithChildren- Returns:
- true, if the node is in the list
-
getChild
public Element getChild(java.lang.String path)
Description copied from interface:ParentFind a child element (not a node!) by path
-
getType
public XMLTokenizer.Type getType()
Description copied from interface:NodeGet 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:NodeFast way to convert many nodes to XML- Specified by:
toXMLin interfaceNode- Overrides:
toXMLin 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:NodeSimulate clone()- Specified by:
createClonein interfaceNode
-
copy
public Document copy(Node orig)
Description copied from interface:NodeCopy all data fromorigintothis- Specified by:
copyin interfaceNode- Overrides:
copyin classNodeWithChildren
-
copy
public Document copy()
Description copied from interface:NodeSimulate clone()- Specified by:
copyin interfaceNode- Overrides:
copyin classNodeWithChildren
-
iterator
public TreeIterator iterator()
-
-