org.planx.xmlstore.koala.io
Interface IOPolicy<R>

All Known Implementing Classes:
SimpleIOPolicy, StoragePolicy

public interface IOPolicy<R>

An IOPolicy handles policies related to converting nodes to and from byte representation as well as discrimination.

Author:
Thomas Ambus

Method Summary
 RawNode chooseCanonical(List<org.planx.msd.graph.Compactor.Edge> eqCls)
          Called during discrimination to choose the canonical node from among an equivalence class of nodes.
 void hardAddEdge(Locator parent, int childIndex, Locator childLoc)
          Informs that the child identified by (parent, childIndex) has been saved (or was already saved) with Locator childLoc.
 Locator hardResolve(Locator parent, int childIndex, Locator child)
          Completely resolves any indirections that may exist along the edge from (parent, childIndex) to child and returns a Locator pointing to the actual child.
 boolean isOutside(Locator parent, int childIndex, Locator child)
          Returns true if the child with the specified Locator should be considered outside of the discrimination area, and false if the node is inside.
 SystemNode loadChild(Locator parent, int childIndex, Locator child, RelativeDualReference<Locator,R> parentRef)
          Loads a child node with the specified Locator.
 Locator location(SystemNode node)
          If the node is already saved, returns a Locator to its position.
 void moveEdge(Locator parent, int childIndex, Locator oldChild, Locator newChild)
          Informs that a child pointer has been rewritten.
 void moveGlobalRoot(Locator oldLoc, Locator newLoc)
          Informs of the moving/merging of a global root, that is, a root referenced by an application.
 void moveLocalRoot(Locator oldLoc, Locator newLoc)
          Informs of the moving/merging of a local root, that is, a root referenced from outside the discrimination area.
 void nodeSaved(SystemNode node, Locator loc)
          Informs that a node has been saved at the specified location.
 void refreshAfter()
          Should refresh incoming and outgoing edges if necessary.
 void refreshBefore()
          Should refresh incoming and outgoing edges if necessary.
 Locator resolveRoot(Locator root)
           
 void save(RawNode node)
          Called after discrimination to allow a live node to synchronize unwritten state changes with its byte representation.
 void softAddEdge(Locator parent, int childIndex, Locator child)
          Informs of the existence of an outgoing edge from a segment.
 Locator softResolve(Locator parent, int childIndex, Locator child)
          Lazily resolves any indirections that may exist along the edge from (parent, childIndex) to child and returns a Locator pointing to the actual child.
 

Method Detail

location

Locator location(SystemNode node)
                 throws IOException
If the node is already saved, returns a Locator to its position. Otherwise returns null.

Throws:
IOException

nodeSaved

void nodeSaved(SystemNode node,
               Locator loc)
               throws IOException
Informs that a node has been saved at the specified location. Allows an implementation to choose to cache the locator in the node if desired.

Called when a SystemNode has been written in byte representation.

Throws:
IOException

hardResolve

Locator hardResolve(Locator parent,
                    int childIndex,
                    Locator child)
                    throws IOException
Completely resolves any indirections that may exist along the edge from (parent, childIndex) to child and returns a Locator pointing to the actual child.

Called when a node is being translated from byte representation.

Throws:
IOException

softResolve

Locator softResolve(Locator parent,
                    int childIndex,
                    Locator child)
                    throws IOException
Lazily resolves any indirections that may exist along the edge from (parent, childIndex) to child and returns a Locator pointing to the actual child. Lazily means resolving indirections without incurring a high cost (accessing secondary storage, etc.).

Called when a node is being translated from byte representation.

Throws:
IOException

resolveRoot

Locator resolveRoot(Locator root)
                    throws IOException
Throws:
IOException

loadChild

SystemNode loadChild(Locator parent,
                     int childIndex,
                     Locator child,
                     RelativeDualReference<Locator,R> parentRef)
                     throws IOException
Loads a child node with the specified Locator. The method is useful for allowing loads of foreign nodes. The method can also be used to decide whether to proxy child nodes or load them recursively.

Called when a node is being translated from byte representation.

Throws:
IOException

isOutside

boolean isOutside(Locator parent,
                  int childIndex,
                  Locator child)
                  throws IOException
Returns true if the child with the specified Locator should be considered outside of the discrimination area, and false if the node is inside.

Called during discrimination.

Throws:
IOException

chooseCanonical

RawNode chooseCanonical(List<org.planx.msd.graph.Compactor.Edge> eqCls)
                        throws IOException
Called during discrimination to choose the canonical node from among an equivalence class of nodes.

Called during discrimination.

Throws:
IOException

save

void save(RawNode node)
          throws IOException
Called after discrimination to allow a live node to synchronize unwritten state changes with its byte representation.

Called after discrimination.

Throws:
IOException

refreshBefore

void refreshBefore()
                   throws IOException
Should refresh incoming and outgoing edges if necessary.

Called before discrimination.

Throws:
IOException

refreshAfter

void refreshAfter()
                  throws IOException
Should refresh incoming and outgoing edges if necessary.

Called after discrimination.

Throws:
IOException

hardAddEdge

void hardAddEdge(Locator parent,
                 int childIndex,
                 Locator childLoc)
                 throws IOException
Informs that the child identified by (parent, childIndex) has been saved (or was already saved) with Locator childLoc.

Called when a SystemNode is being written in byte representation.

Throws:
IOException

moveEdge

void moveEdge(Locator parent,
              int childIndex,
              Locator oldChild,
              Locator newChild)
              throws IOException
Informs that a child pointer has been rewritten.

Called when a node is being translated from byte representation.

Throws:
IOException

softAddEdge

void softAddEdge(Locator parent,
                 int childIndex,
                 Locator child)
                 throws IOException
Informs of the existence of an outgoing edge from a segment. All edges going out of a segment are removed before discrimination and remaining ones are added after discrimination.

Called after discrimination.

Throws:
IOException

moveLocalRoot

void moveLocalRoot(Locator oldLoc,
                   Locator newLoc)
                   throws IOException
Informs of the moving/merging of a local root, that is, a root referenced from outside the discrimination area.

Called after discrimination.

Throws:
IOException

moveGlobalRoot

void moveGlobalRoot(Locator oldLoc,
                    Locator newLoc)
                    throws IOException
Informs of the moving/merging of a global root, that is, a root referenced by an application.

Called after discrimination.

Throws:
IOException


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