ti.chimera.registry
Class RegistryCore

java.lang.Object
  extended byti.chimera.registry.RegistryCore
Direct Known Subclasses:
Registry

public abstract class RegistryCore
extends java.lang.Object

The implementation of the "core" registry API.

Version:
0.1
Author:
;Rob Clark;a0873619;San Diego;;

Nested Class Summary
static class RegistryCore.DirectoryNode
          A directory-node.
 
Field Summary
protected  Main main
          link to main
protected  Node root
          The root node.
 
Constructor Summary
protected RegistryCore(Main main)
          Class Constructor.
 
Method Summary
static java.lang.String basename(java.lang.String path)
          Given a normalized path, return basename.
static java.lang.String dirname(java.lang.String path)
          Given a normalized path, return dirname.
 boolean exists(java.lang.String path)
          Determine if the node at the specified path exists.
 void link(Node node, java.lang.String path)
          Link in a new node to the specified path.
 Node mkdir(java.lang.String path)
          Create a directory node, if one does not already exist.
static java.lang.String normalize(java.lang.String path)
          Normalize the path.
 Node resolve(java.lang.String path)
          Find the node at the specified path.
 void unlink(java.lang.String path)
          Unlink a node.
 void unlink(java.lang.String path, boolean recursive)
          Unlink a node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

main

protected Main main
link to main


root

protected final Node root
The root node.

Constructor Detail

RegistryCore

protected RegistryCore(Main main)
Class Constructor.

Method Detail

link

public void link(Node node,
                 java.lang.String path)
          throws RegistryException
Link in a new node to the specified path. This will make the node a part of the registry, so it will be accessible by other parts of the system. It is permitted for the same node to be link() in to multiple locations in the tree. The link() operation will cause the parent directory to be created, if needed.

Parameters:
node - the node to link in
path - the path to link the node in to
Throws:
RegistryException - if a node is already linked in at the specified path
See Also:
unlink(java.lang.String), mkdir(java.lang.String)

unlink

public void unlink(java.lang.String path)
            throws RegistryException
Unlink a node. This will remove a link to the node from the tree, and if there are no more references to the node could result in the node being garbage collected.

Parameters:
path - the path to the node to unlink
Throws:
RegistryException - if there is no node linked in at the specified path, or if this is the last link to a directory node that still has children
See Also:
link(ti.chimera.registry.Node, java.lang.String), mkdir(java.lang.String)

unlink

public void unlink(java.lang.String path,
                   boolean recursive)
            throws RegistryException
Unlink a node. This will remove a link to the node from the tree, and if there are no more references to the node could result in the node being garbage collected.

Parameters:
path - the path to the node to unlink
recursive - if true, and the specified node is a directory node, then child nodes are recursively unlinked
Throws:
RegistryException - if there is no node linked in at the specified path, or if this is the last link to a directory node that still has children and recursive is false
See Also:
link(ti.chimera.registry.Node, java.lang.String), mkdir(java.lang.String)

resolve

public Node resolve(java.lang.String path)
             throws RegistryException
Find the node at the specified path.

Parameters:
path - the path to the node to resolve
Throws:
RegistryException - if there is no node linked in at the specified path

exists

public boolean exists(java.lang.String path)
Determine if the node at the specified path exists.

Parameters:
path - the path to the node
Returns:
true if node exists, else false

mkdir

public Node mkdir(java.lang.String path)
Create a directory node, if one does not already exist. Recursively creates parent directories if needed.

Parameters:
path - the path to the node to unlink
Returns:
the created node

normalize

public static java.lang.String normalize(java.lang.String path)
Normalize the path. This involves ensuring the path is fully qualified (begins with "/"), and gets rid of any extra "." and "/".


dirname

public static java.lang.String dirname(java.lang.String path)
Given a normalized path, return dirname. Ie. everything but the last component in the path.


basename

public static java.lang.String basename(java.lang.String path)
Given a normalized path, return basename. Ie. the last component of the path.