org.planx.xmlstore.koala.storage
Class RootManager

java.lang.Object
  extended by org.planx.xmlstore.koala.storage.RootManager

public class RootManager
extends Object

The RootManager keeps track of live roots.

TODO: Improve O(N) time complexity in getRoots(org.planx.io.SourceId).

Author:
Thomas Ambus

Constructor Summary
RootManager()
           
 
Method Summary
 void addRootListener(LocatorListener l)
           
 void addWeakRoot(LocalLocator loc)
          Adds the specified LocalLocator as a transient root.
 LocalLocator asWeakRoot(LocalLocator loc)
           
 List<Locator> getRoots()
           
 List<Locator> getRoots(SourceId fsi)
          Returns all live roots with the specified SourceId.
static SizeStreamer<RootManager> getStreamer()
           
 LocalLocator lookup(LocalLocator loc)
           
 LocalLocator lookup(Locator loc)
          Returns the canonical LocalLocator for the specified Locator or null if the locator is not a root.
 void move(LocalLocator old, LocalLocator canonic)
          Informs the RootManager that two existing roots are equivalent and will be merged.
 void move(Locator old, Locator canonic)
           
 void release(LocalLocator loc)
          Releases a root that was previously retained.
 void removeRootListener(LocatorListener l)
           
 void retain(LocalLocator loc)
          Requests that a root be kept permanently alive.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RootManager

public RootManager()
Method Detail

addWeakRoot

public void addWeakRoot(LocalLocator loc)
Adds the specified LocalLocator as a transient root. That is, it will disappear when it goes out of runtime scope unless retain is called.


lookup

public LocalLocator lookup(Locator loc)
Returns the canonical LocalLocator for the specified Locator or null if the locator is not a root.


lookup

public LocalLocator lookup(LocalLocator loc)

asWeakRoot

public LocalLocator asWeakRoot(LocalLocator loc)

getRoots

public List<Locator> getRoots(SourceId fsi)
Returns all live roots with the specified SourceId.

TODO: Currently, O(N) time complexity - should be improved.


getRoots

public List<Locator> getRoots()

retain

public void retain(LocalLocator loc)
Requests that a root be kept permanently alive.


release

public void release(LocalLocator loc)
             throws UnknownReferenceException
Releases a root that was previously retained.

Throws:
UnknownReferenceException

addRootListener

public void addRootListener(LocatorListener l)

removeRootListener

public void removeRootListener(LocatorListener l)

move

public void move(LocalLocator old,
                 LocalLocator canonic)
Informs the RootManager that two existing roots are equivalent and will be merged. The first argument is a root that will no longer be used, and the second argument is a canonical root. If the roots are permanent roots, their reference counts are added and stored under the canonic root. Also, the weak root old is removed to ensure the consistency of the internal hash table. (When the LocalLocator.move method is called the hash code of the old root may change messing up the hash table.)


move

public void move(Locator old,
                 Locator canonic)

toString

public String toString()
Overrides:
toString in class Object

getStreamer

public static SizeStreamer<RootManager> getStreamer()


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