org.planx.xmlstore.koala.nodes
Class DVMNodeFactory

java.lang.Object
  extended by org.planx.xmlstore.NodeFactory
      extended by org.planx.xmlstore.koala.nodes.DVMNodeFactory

public final class DVMNodeFactory
extends NodeFactory

An implementation of NodeFactory that operates strictly on SystemNodes. The preferred way to obtain a SystemNode from an unknown Node (which may already be a SystemNode) is not to cast it but to use the convert(Node) method provided here.

Author:
Kasper Bøgebjerg, Henning Niss, Thomas Ambus

Constructor Summary
DVMNodeFactory()
           
 
Method Summary
static SystemNode convert(Node n)
          Additional method that converts any Node to a SystemNode.
 Attribute createAttribute(String name, String value)
           
 Node createBinaryNode(byte[] data)
           
 Node createCharDataNode(String data)
           
 Node createElementNode(String tagName)
           
 Node createElementNode(String tagName, List<? extends Node> children)
           
 Node createElementNode(String tagName, List<? extends Node> children, List<Attribute> attrs)
           
 Node createElementNode(String tagName, Node... children)
           
 Node createElementNode(String tagName, Node[] children, Attribute[] attrs)
           
<R extends Reference>
Node
createProxy(XMLStore<R> xmlstore, R ref)
          Use this to convert a reference to a node without loading data.
 Node insertChild(Node n, int index, Node child)
          The method is used for adding a child to an element node.
 Node removeChild(Node n, int index)
          The method is used for removing a child from an element node.
 Node replaceChild(Node node, int index, Node child)
          The method is used for replacing a child of an element node.
 
Methods inherited from class org.planx.xmlstore.NodeFactory
instance
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DVMNodeFactory

public DVMNodeFactory()
Method Detail

createAttribute

public Attribute createAttribute(String name,
                                 String value)
Specified by:
createAttribute in class NodeFactory

createElementNode

public Node createElementNode(String tagName)
Specified by:
createElementNode in class NodeFactory

createElementNode

public Node createElementNode(String tagName,
                              List<? extends Node> children)
Specified by:
createElementNode in class NodeFactory

createElementNode

public Node createElementNode(String tagName,
                              List<? extends Node> children,
                              List<Attribute> attrs)
Specified by:
createElementNode in class NodeFactory

createElementNode

public Node createElementNode(String tagName,
                              Node... children)
Specified by:
createElementNode in class NodeFactory

createElementNode

public Node createElementNode(String tagName,
                              Node[] children,
                              Attribute[] attrs)
Specified by:
createElementNode in class NodeFactory

createCharDataNode

public Node createCharDataNode(String data)
Specified by:
createCharDataNode in class NodeFactory

createBinaryNode

public Node createBinaryNode(byte[] data)
Specified by:
createBinaryNode in class NodeFactory

createProxy

public <R extends Reference> Node createProxy(XMLStore<R> xmlstore,
                                              R ref)
Description copied from class: NodeFactory
Use this to convert a reference to a node without loading data. This is useful during saving of large documents. First, save a portion of the data in XMLStore. Second, create a proxy node to the data using this method. This will allow XMLStore to save the data to disk and flush nodes from memory. Make sure you do not yourself hold any pointers to the data saved through any other means than the proxy node created by this method.

Specified by:
createProxy in class NodeFactory

convert

public static SystemNode convert(Node n)
Additional method that converts any Node to a SystemNode. If it is already a SystemNode it will merely be cast.


replaceChild

public Node replaceChild(Node node,
                         int index,
                         Node child)
Description copied from class: NodeFactory
The method is used for replacing a child of an element node. The replacement is done by constructing and returning a new element node, which only differs from the original element node in the replaced child.

Specified by:
replaceChild in class NodeFactory
Parameters:
node - element node.
index - index of the child to replace.
child - new child node.
Returns:
new element node.

insertChild

public Node insertChild(Node n,
                        int index,
                        Node child)
Description copied from class: NodeFactory
The method is used for adding a child to an element node. This is done by constructing and returning a new element node, which only differs from the original element node in the added child.

Specified by:
insertChild in class NodeFactory
Parameters:
n - element node.
index - index at which new child is inserted.
child - new child node.
Returns:
new element node.

removeChild

public Node removeChild(Node n,
                        int index)
Description copied from class: NodeFactory
The method is used for removing a child from an element node. This is done by constructing and returning a new element node, which only differs from the original element node in the removed child.

Specified by:
removeChild in class NodeFactory
Parameters:
n - element node.
index - index specifying the child to remove
Returns:
new element node.


Copyright © 2004-2005 Plan-X. All Rights Reserved.