Package de.pdark.decentxml
Class Document
java.lang.Object
de.pdark.decentxml.NodeWithChildren
de.pdark.decentxml.Document
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate DocType
private Namespaces
private Element
private XMLDeclaration
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddNodes
(int index, Collection<? extends Node> nodes) addNodes
(Collection<? extends Node> nodes) protected void
copy()
Simulate clone()Copy all data fromorig
intothis
Simulate clone()protected XMLDeclaration
Find a child element (not a node!) by pathgetNamespace
(String prefix) getType()
Get the node typeboolean
iterator()
void
Parse a possible XML declaration and fill the internal fields with the data.removeNode
(int index) Remove a node from the listboolean
removeNode
(Node n) Remove a node from the listvoid
setDocType
(DocType docType) setEncoding
(String encoding) void
setNamespaces
(Namespaces namespaces) setRootNode
(Element rootNode) void
setStandalone
(boolean standalone) setVersion
(String version) void
setXmlDeclaration
(XMLDeclaration xmlDeclaration) Fast way to convert many nodes to XMLMethods 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
-
Field Details
-
rootNode
-
xmlDeclaration
-
docType
-
namespaces
-
-
Constructor Details
-
Document
public Document() -
Document
-
-
Method Details
-
addNode
- Specified by:
addNode
in interfaceParent
- Overrides:
addNode
in classNodeWithChildren
-
addNode
- Specified by:
addNode
in interfaceParent
- Overrides:
addNode
in classNodeWithChildren
-
addNodes
- Specified by:
addNodes
in interfaceParent
- Overrides:
addNodes
in classNodeWithChildren
-
addNodes
- Specified by:
addNodes
in interfaceParent
- Overrides:
addNodes
in classNodeWithChildren
-
addNodes
- Specified by:
addNodes
in interfaceParent
- Overrides:
addNodes
in classNodeWithChildren
-
addNodes
- Specified by:
addNodes
in interfaceParent
- Overrides:
addNodes
in classNodeWithChildren
-
removeNode
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
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
Description copied from interface:Parent
Find a child element (not a node!) by path -
getChild
-
getType
Description copied from interface:Node
Get the node type -
getRootElement
-
setRootNode
-
getXmlDeclaration
-
setXmlDeclaration
-
getVersion
-
setVersion
-
createXMLDeclaration
-
getEncoding
-
setEncoding
-
isStandalone
public boolean isStandalone() -
setStandalone
public void setStandalone(boolean standalone) -
toXML
Description copied from interface:Node
Fast way to convert many nodes to XML- Specified by:
toXML
in interfaceNode
- Overrides:
toXML
in classNodeWithChildren
- Throws:
IOException
-
parseXMLDeclaration
public void parseXMLDeclaration()Parse a possible XML declaration and fill the internal fields with the data. -
clearXMLDeclaration
protected void clearXMLDeclaration() -
getDocType
-
setDocType
-
getNamespaces
-
setNamespaces
-
getNamespace
-
createClone
Description copied from interface:Node
Simulate clone()- Specified by:
createClone
in interfaceNode
-
copy
Description copied from interface:Node
Copy all data fromorig
intothis
- Specified by:
copy
in interfaceNode
- Overrides:
copy
in classNodeWithChildren
-
copy
Description copied from interface:Node
Simulate clone()- Specified by:
copy
in interfaceNode
- Overrides:
copy
in classNodeWithChildren
-
iterator
-