ti.chimera.registry
Class DirectoryTable

java.lang.Object
  extended byti.chimera.registry.DirectoryTable

public class DirectoryTable
extends java.lang.Object

A directory node is simply a regular node whose contents is a directory table. A directory table is an immutable table, which maps node names to nodes. A directory table can only be created empty, and only way to mutate one (ie. add or remove a child) is by using the #add or #remove methods, which return a new directory table. The table also implements notIn(ti.chimera.registry.DirectoryTable) to compare two directory tables and determine the differences between the two. (Note the notIn(ti.chimera.registry.DirectoryTable) comparision does not need to be made between successive versions of a directory table, but can be made between arbitrary directory tables.)

The directory table is mainly used internally by the registry.

Note that the current table implementation isn't particularly clever and basically all operations are O(n) where n is number of children, except notIn(ti.chimera.registry.DirectoryTable) which is O(n^2).

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

Constructor Summary
DirectoryTable()
          Class Constructor, create an empty directory table.
 
Method Summary
 Node get(java.lang.String name)
          Get the node in this table with the specified name.
 int getChildCount()
          Get the number of children of this directory node.
 java.util.Iterator getChildNames()
          Get an iterator of child names of the contents of this directory.
 java.util.Iterator notIn(DirectoryTable otherTable)
          Determine the differences between directory tables, by returning an array of files that are only contained in this table.
 java.lang.String toString()
          for debug...
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DirectoryTable

public DirectoryTable()
Class Constructor, create an empty directory table.

Method Detail

getChildNames

public java.util.Iterator getChildNames()
Get an iterator of child names of the contents of this directory.

Returns:
an iterator of child names

getChildCount

public int getChildCount()
Get the number of children of this directory node.

Returns:
the number of children
See Also:
#getChildName, #getChildNode

get

public Node get(java.lang.String name)
Get the node in this table with the specified name. Returns null if none.

Parameters:
name - name of node to find
Returns:
the requested node, or null if none

notIn

public java.util.Iterator notIn(DirectoryTable otherTable)
Determine the differences between directory tables, by returning an array of files that are only contained in this table. For example:
   Iterator added   = newDirTable.notIn(oldDirTable);
   Iterator removed = oldDirTable.notIn(newDirTable);
 
If otherTable is null, this returns the same thing as getChildNames().

Parameters:
otherTable - the other table to compare to, or null
Returns:
an iterator of names of children that exist in this table but not otherTable

toString

public java.lang.String toString()
for debug...