org.planx.xmlstore.koala.io
Class VirtualRawNode

java.lang.Object
  extended by org.planx.xmlstore.koala.io.RawNode
      extended by org.planx.xmlstore.koala.io.VirtualRawNode

public class VirtualRawNode
extends RawNode

A RawNode that only exists in memory and have no underlying byte representation. This type of node is useful for roots of a graph. That is, nodes that are not part of the actual data but merely used for 'administration'.

A VirtualRawNode is given a unique Locator to identify it. The locator has a SourceId provided in the constructor. To distinguish it from other nodes, it is given a fake locator position equal to minus a unique number. This way it will never be equivalent to a real node (with a positive position), and is improbable to be (wrongly) equivalent with another VirtualRawNode.

Author:
Thomas Ambus

Constructor Summary
VirtualRawNode(SourceId fsi, List<RawNode> children)
           
VirtualRawNode(SourceId fsi, List<RawNode> children, byte val)
          Constructs a VirtualRawNode with the specified children that will act as if it is associated with the specified SourceId.
 
Method Summary
 int childCount()
           
 List<List<Byte>> getAttributes()
          Return the empty list.
 RawNode getChild(NodeFileSystem fs, int index)
           
 List<Locator> getChildren()
          Returns the locators of the children given in the constructor.
 byte getType()
          Returns ELEMENT.
 List<Byte> getValue()
           
 boolean isDirty(int index)
           
 boolean isVirtual()
           
 Locator save(NodeFileSystem fs, boolean doLazySave)
          Does nothing.
 void setChild(int index, Locator child)
           
 void setChild(int index, RawNode child)
          Changes a child pointer of this node in its in-memory representation.
 void setIsShared(boolean isShared)
          Does nothing.
 long size()
          Returns the number of bytes that the byte representation of this RawNode occupies.
 String toString()
           
 
Methods inherited from class org.planx.xmlstore.koala.io.RawNode
createNode, equals, getHeight, getLocator, getVisitToken, hashCode, setHeight, setVisitToken
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VirtualRawNode

public VirtualRawNode(SourceId fsi,
                      List<RawNode> children)

VirtualRawNode

public VirtualRawNode(SourceId fsi,
                      List<RawNode> children,
                      byte val)
Constructs a VirtualRawNode with the specified children that will act as if it is associated with the specified SourceId. More specifically, the RawNode.getLocator() method will return a Locator with the specified SourceId.

Method Detail

save

public Locator save(NodeFileSystem fs,
                    boolean doLazySave)
             throws IOException
Does nothing.

Specified by:
save in class RawNode
Throws:
IOException

setIsShared

public void setIsShared(boolean isShared)
                 throws IOException
Does nothing.

Specified by:
setIsShared in class RawNode
Throws:
IOException

isVirtual

public boolean isVirtual()
Specified by:
isVirtual in class RawNode

getType

public byte getType()
Returns ELEMENT.

Specified by:
getType in class RawNode

getValue

public List<Byte> getValue()
Specified by:
getValue in class RawNode

getAttributes

public List<List<Byte>> getAttributes()
Return the empty list.

Specified by:
getAttributes in class RawNode

getChildren

public List<Locator> getChildren()
Returns the locators of the children given in the constructor.

Specified by:
getChildren in class RawNode

childCount

public int childCount()
Specified by:
childCount in class RawNode

getChild

public RawNode getChild(NodeFileSystem fs,
                        int index)
                 throws IOException
Specified by:
getChild in class RawNode
Throws:
IOException

setChild

public void setChild(int index,
                     Locator child)
              throws IOException
Specified by:
setChild in class RawNode
Throws:
IOException

setChild

public void setChild(int index,
                     RawNode child)
              throws IOException
Description copied from class: RawNode
Changes a child pointer of this node in its in-memory representation. The actual update of the underlying byte representation can be postponed until the RawNode.save(NodeFileSystem,boolean) method is called.

Specified by:
setChild in class RawNode
Throws:
IOException

isDirty

public boolean isDirty(int index)
Specified by:
isDirty in class RawNode

size

public long size()
Description copied from class: RawNode
Returns the number of bytes that the byte representation of this RawNode occupies.

Specified by:
size in class RawNode

toString

public String toString()
Overrides:
toString in class RawNode


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