de.pdark.decentxml
Class NodeWithChildren

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

public abstract class NodeWithChildren
extends java.lang.Object
implements Parent

This class contains all the code necessary to implement nodes which can have child nodes (like Document or Element).

Author:
digulla

Constructor Summary
NodeWithChildren()
           
 
Method Summary
 NodeWithChildren addNode(int index, Node node)
           
 NodeWithChildren addNode(Node node)
           
 NodeWithChildren addNodes(java.util.Collection<? extends Node> nodes)
           
 NodeWithChildren addNodes(int index, java.util.Collection<? extends Node> nodes)
           
 NodeWithChildren addNodes(int index, Node... nodes)
           
 NodeWithChildren addNodes(Node... nodes)
           
 NodeWithChildren clearNodes()
          Remove all nodes
 NodeWithChildren copy()
          Simulate clone()
 NodeWithChildren copy(Node orig)
          Copy all data from orig into this
 Node getNode(int index)
          Get a specific node from the list
 java.util.List<Node> getNodes()
          Get the list of child nodes.
 java.util.List<Node> getNodes(NodeFilter filter)
           
 boolean hasNodes()
          Does this node have children?
 int nodeCount()
          The number of nodes in the list
 int nodeIndexOf(Node node)
          The index of the node in the node list or -1 if it isn't in the list
 Node removeNode(int index)
          Remove a node from the list
 boolean removeNode(Node n)
          Remove a node from the list
 java.lang.String toString()
           
 java.lang.String toXML()
          Slow way to convert a node to XML
 NodeWithChildren toXML(XMLWriter writer)
          Fast way to convert many nodes to XML
 
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
getChild
 
Methods inherited from interface de.pdark.decentxml.Node
createClone, getType
 

Constructor Detail

NodeWithChildren

public NodeWithChildren()
Method Detail

addNode

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

addNode

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

addNodes

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

addNodes

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

addNodes

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

addNodes

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

getNodes

public java.util.List<Node> getNodes()
Description copied from interface: Parent
Get the list of child nodes.

CAUTION: Changes to this list will modify the actual data structure! So don't do this unless you know what you're doing!

Specified by:
getNodes in interface Parent

hasNodes

public boolean hasNodes()
Description copied from interface: Parent
Does this node have children?

Specified by:
hasNodes in interface Parent

nodeCount

public int nodeCount()
Description copied from interface: Parent
The number of nodes in the list

Specified by:
nodeCount in interface Parent

nodeIndexOf

public int nodeIndexOf(Node node)
Description copied from interface: Parent
The index of the node in the node list or -1 if it isn't in the list

Specified by:
nodeIndexOf in interface Parent

getNode

public Node getNode(int index)
Description copied from interface: Parent
Get a specific node from the list

Specified by:
getNode in interface Parent

removeNode

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

Specified by:
removeNode in interface Parent
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
Returns:
true, if the node is in the list

getNodes

public java.util.List<Node> getNodes(NodeFilter filter)

clearNodes

public NodeWithChildren clearNodes()
Description copied from interface: Parent
Remove all nodes

Specified by:
clearNodes in interface Parent

toXML

public java.lang.String toXML()
Description copied from interface: Node
Slow way to convert a node to XML

Specified by:
toXML in interface Node

toXML

public NodeWithChildren 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
Throws:
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

copy

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

Specified by:
copy in interface Node

copy

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

Specified by:
copy in interface Node


Copyright © 2008-2011. All Rights Reserved.