| java.lang.Object ti.chimera.registry.DirectoryTable
DirectoryTable | public class DirectoryTable (Code) | | 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
DirectoryTable.add or
DirectoryTable.remove methods, which return a new directory table. The table
also implements
DirectoryTable.notIn to compare two directory tables and
determine the differences between the two. (Note the
DirectoryTable.notIn 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
DirectoryTable.notIn which is O(n^2).
author: ;Rob Clark;a0873619;San Diego;; version: 0.1 |
Constructor Summary | |
public | DirectoryTable() Class Constructor, create an empty directory table. |
Method Summary | |
DirectoryTable | add(Node node, String name) Construct a directory table whose contents is the same as the
current table, with the specified node added. | public Node | get(String name) Get the node in this table with the specified name. | public int | getChildCount() Get the number of children of this directory node. | String | getChildName(int idx) Get the name of the child at the specified index. | public Iterator | getChildNames() Get an iterator of child names of the contents of this directory. | Node | getChildNode(int idx) Get the node of the child at the specified index. | public Iterator | notIn(DirectoryTable otherTable) Determine the differences between directory tables, by returning
an array of files that are only contained in this table. | DirectoryTable | remove(String name, boolean errIfLastLink) Construct a directory table whose contents is the same as the
current table, with the specified node removed. | public String | toString() for debug... |
DirectoryTable | public DirectoryTable()(Code) | | Class Constructor, create an empty directory table.
|
add | DirectoryTable add(Node node, String name) throws RegistryException(Code) | | Construct a directory table whose contents is the same as the
current table, with the specified node added. Called by the
registry when linking a new node into the tree, this should
not be called anywhere else. (Nothing to see here, move
along.)
Parameters: node - the node to add Parameters: name - name of node to add the new directory table throws: RegistryException - already contains node with same name |
get | public Node get(String name)(Code) | | Get the node in this table with the specified name. Returns
null if none.
Parameters: name - name of node to find the requested node, or null if none |
getChildName | String getChildName(int idx)(Code) | | Get the name of the child at the specified index.
Parameters: idx - the index the child name |
getChildNames | public Iterator getChildNames()(Code) | | Get an iterator of child names of the contents of this directory.
an iterator of child names |
getChildNode | Node getChildNode(int idx)(Code) | | Get the node of the child at the specified index.
Parameters: idx - the index the child name |
notIn | public Iterator notIn(DirectoryTable otherTable)(Code) | | 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
DirectoryTable.getChildNames .
Parameters: otherTable - the other table to compare to, or null an iterator of names of children that exist in this tablebut not otherTable |
remove | DirectoryTable remove(String name, boolean errIfLastLink) throws RegistryException(Code) | | Construct a directory table whose contents is the same as the
current table, with the specified node removed. If an attempt
is made to remove a child who is a non-empty directory, this
will throw an exception, because much depends on being able to
detect a node being removed by detecting a change in the node's
parent. Called by the registry when unlinking a node from the
tree, this should not be called by anyone else.
Parameters: name - name of node to remove Parameters: errIfLastLink - should we throw an exception if this link to the node is the last throws: RegistryException - does not contain node with same nameor if said node is a directory node that still has childrenand errIfLastLink is true |
|
|