Voyager ORB

com.objectspace.voyager.directory
Class Directory

java.lang.Object
  |
  +--com.objectspace.voyager.directory.Directory

public class Directory
extends java.lang.Object
implements IDirectory, IRemote, java.io.Serializable

Directory is the building block of Voyager's federating naming service. You can use this service to place an object into a distributed hierarchical naming structure. This structure allows you to associate objects with symbolic path names comprised of simple strings separated by ‘/’ characters such as chemistry/symbol/calcium or chemistry/number/gold.

To create a naming structure, construct a Directory object. You may use put() to associate a simple string with an object, including a remote reference to another Directory. If you invoke put() with a path name, it automatically looks up the Directory associated with the head of the path name and then forwards the put() message with the remaining tail of the path name. If the head is not present or is not associated with an Directory, a DirectoryException is thrown. The same logic applies to get() and remove().

Directories are serializable.

Version:
3.0
See Also:
Serialized Form

Field Summary
protected static byte ALL_ENTRY
           
protected static byte DIRECTORY_ENTRY
           
protected  java.util.Dictionary map
           
protected static byte OBJECT_ENTRY
           
 
Constructor Summary
Directory()
          Construct myself to be an empty directory.
 
Method Summary
 void clear()
          Remove every entry from the local directory.
 java.lang.Object get(java.lang.String key)
          Return the value associated with a particular key.
 Entry[] getAllEntries(java.lang.String key)
           
 Entry[] getDirectoryEntries(java.lang.String key)
           
protected  Entry[] getEntries(byte type)
           
 java.lang.Object[] getKeys()
          Return an array of the keys in the local directory.
 Entry[] getObjectEntries(java.lang.String key)
           
 java.lang.Object[] getValues()
          Return an array of the values in the local directory.
protected  void initialize()
           
protected  IDirectory newDirectory(java.lang.String name)
           
protected  Entry newEntry(java.lang.String name, java.lang.Object object)
           
 java.lang.Object put(java.lang.String key, java.lang.Object value)
          Associate a key with a value.
 java.lang.Object remove(java.lang.String key)
          Remove the directory entry with the specified key.
protected  java.lang.Object resolveValue(java.lang.Object object)
           
 int size()
          Return the number of keys in the local directory.
 java.lang.String toString()
          Return a string that describes me.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

OBJECT_ENTRY

protected static final byte OBJECT_ENTRY

DIRECTORY_ENTRY

protected static final byte DIRECTORY_ENTRY

ALL_ENTRY

protected static final byte ALL_ENTRY

map

protected java.util.Dictionary map
Constructor Detail

Directory

public Directory()
Construct myself to be an empty directory.
Method Detail

initialize

protected void initialize()

toString

public java.lang.String toString()
Return a string that describes me.
Overrides:
toString in class java.lang.Object

put

public java.lang.Object put(java.lang.String key,
                            java.lang.Object value)
                     throws DirectoryException
Associate a key with a value. If key is a simple string, associate it with the specified value in the local directory. If key is a path, look up the IDirectory associated with the head of the path name and then forward the put() message with the remaining tail of the path name. Return the value that was previously associated with the key, or null if there was none.
Specified by:
put in interface IDirectory
Parameters:
key - The key.
value - The value to be associated with the key.
Throws:
DirectoryException - The key was a path whose head was not an IDirectory.

get

public java.lang.Object get(java.lang.String key)
                     throws DirectoryException
Return the value associated with a particular key. If key is a simple string, return its associated value in the local directory or null if there is none. If key is a path, look up the IDirectory associated with the head of the path name and then forward the get() message with the remaining tail of the path name.
Specified by:
get in interface IDirectory
Parameters:
key - The key.
Throws:
DirectoryException - The key was a path whose head was not an IDirectory.

getAllEntries

public Entry[] getAllEntries(java.lang.String key)
                      throws DirectoryException
Specified by:
getAllEntries in interface IDirectory

getObjectEntries

public Entry[] getObjectEntries(java.lang.String key)
                         throws DirectoryException
Specified by:
getObjectEntries in interface IDirectory

getDirectoryEntries

public Entry[] getDirectoryEntries(java.lang.String key)
                            throws DirectoryException
Specified by:
getDirectoryEntries in interface IDirectory

remove

public java.lang.Object remove(java.lang.String key)
                        throws DirectoryException
Remove the directory entry with the specified key. If key is a simple string, remove its entry from the local directory. If key is a path, look up the IDirectory associated with the head of the path name and then forward the remove() message with the remaining tail of the path name. Return the value that was associated with the key, or null if there was none.
Specified by:
remove in interface IDirectory
Parameters:
key - The key.
Throws:
DirectoryException - The key was a path whose head was not an IDirectory.

clear

public void clear()
Remove every entry from the local directory. This has no effect on the directories that the local directory used to reference.
Specified by:
clear in interface IDirectory

size

public int size()
Return the number of keys in the local directory.
Specified by:
size in interface IDirectory

getValues

public java.lang.Object[] getValues()
Return an array of the values in the local directory.
Specified by:
getValues in interface IDirectory

getKeys

public java.lang.Object[] getKeys()
Return an array of the keys in the local directory.
Specified by:
getKeys in interface IDirectory

getEntries

protected Entry[] getEntries(byte type)

newEntry

protected Entry newEntry(java.lang.String name,
                         java.lang.Object object)

newDirectory

protected IDirectory newDirectory(java.lang.String name)

resolveValue

protected java.lang.Object resolveValue(java.lang.Object object)

ObjectSpace Inc.

(c) Copyright 1997-1999 ObjectSpace, Inc.
14850 Quorum Drive, Suite 500
Dallas, Texas 75240