org.planx.xmlstore.koala.io
Class NodeConverter<R>

java.lang.Object
  extended by org.planx.xmlstore.koala.io.NodeConverter<R>

public class NodeConverter<R>
extends Object

A NodeConverter is capable of reading and writing SystemNodes to and from byte representation. Some implementation specific tasks are encapsulated in an IOPolicy.

The format of the byte representation is as follows:

Author:
Thomas Ambus

Constructor Summary
NodeConverter(IOPolicy<R> policy)
           
 
Method Summary
static long childLocatorsSize(SourceId id, List<Locator> childLocs)
           
static List<Locator> readChildLocators(PositionalDataInput in)
           
 SystemNode readNode(PositionalDataInput in)
           
 SystemNode readNode(PositionalDataInput in, RelativeDualReference<Locator,R> ref)
          Reads a node from the input and resolves and updates child pointers in the byte representation if the argument is also an instance of PositionalDataOutput.
static boolean updatePointer(PositionalDataOutput out, Locator oldPtr, Locator newPtr)
          Request that a pointer in byte representation be updated to point to a new location.
static void writeChildLocators(PositionalDataOutput out, List<Locator> childLocs)
          Writes a list of Locators representing children to an output.
 Locator writeNode(PositionalDataOutput out, SystemNode node)
          Recursively writes the specified node and all its children to the output.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeConverter

public NodeConverter(IOPolicy<R> policy)
Method Detail

writeNode

public Locator writeNode(PositionalDataOutput out,
                         SystemNode node)
                  throws IOException
Recursively writes the specified node and all its children to the output. The IOPolicy's IOPolicy.nodeSaved(SystemNode, Locator) method will be called once for each node saved.

Throws:
IOException

writeChildLocators

public static void writeChildLocators(PositionalDataOutput out,
                                      List<Locator> childLocs)
                               throws IOException
Writes a list of Locators representing children to an output.

Throws:
IOException

childLocatorsSize

public static long childLocatorsSize(SourceId id,
                                     List<Locator> childLocs)
                              throws IOException
Throws:
IOException

readChildLocators

public static List<Locator> readChildLocators(PositionalDataInput in)
                                       throws IOException
Throws:
IOException

updatePointer

public static boolean updatePointer(PositionalDataOutput out,
                                    Locator oldPtr,
                                    Locator newPtr)
                             throws IOException
Request that a pointer in byte representation be updated to point to a new location. The update is only done if the number of bytes needed to represent the old and new pointer is identical. Returns true if the pointer was successfully updated and false otherwise.

Throws:
IOException

readNode

public SystemNode readNode(PositionalDataInput in)
                    throws IOException
Throws:
IOException

readNode

public SystemNode readNode(PositionalDataInput in,
                           RelativeDualReference<Locator,R> ref)
                    throws IOException
Reads a node from the input and resolves and updates child pointers in the byte representation if the argument is also an instance of PositionalDataOutput.

Throws:
IOException


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