electric.directory
Class Directory

java.lang.Object
  extended byelectric.directory.Directory
All Implemented Interfaces:
IContainer, IDirectory, ILoggingConstants
Direct Known Subclasses:
PersistentDirectory

public class Directory
extends java.lang.Object
implements IDirectory, ILoggingConstants

Directory is an implementation of IDirectory that uses a Dictionary as its underlying storage. By default, a Directory uses a Hashtable as its underlying Dictionary. The electric.util.dictionary package includes other Dictionary implementations such as PersistentDictionary and TransactionalDictionary.

Author:
webMethods

Field Summary
protected  java.util.Dictionary dictionary
           
protected  IDirectory parent
           
 
Fields inherited from interface electric.util.log.ILoggingConstants
CLASSLOADER_EVENT, COMMAND_EVENT, COMMENT_EVENT, CONFIG_EVENT, DEBUG_EVENT, ELECTRIC_LOGGING_PROPERTY, ERROR_EVENT, EXCEPTION_EVENT, FILE_EVENT, LICENSE_EVENT, RESOURCES_EVENT, SECURITY_EVENT, SHUTDOWN_EVENT, SOURCE_EVENT, SQL_EVENT, STARTUP_EVENT, WARNING_EVENT
 
Constructor Summary
Directory()
          Create an empty Directory with no parent and a Hashtable as its underlying Dictionary.
Directory(java.util.Dictionary dictionary)
          Create a Directory with no parent and the specified Dictionary as its underlying storage.
 
Method Summary
 void delete()
          Delete this directory.
 java.util.Enumeration findAll(ISelector selector)
           
 java.lang.Object findFirst(ISelector selector)
           
 java.lang.Object get(java.lang.String path)
          Return the object associated with the the specified path, or null if not found.
 IDirectory getParent()
          Return the parent of this directory, or null if there is none.
protected  electric.directory.Parts getParts(java.lang.String path, boolean create)
          Return a Parts object that contains a broken down version of the specified path.
 java.lang.String getPath(java.lang.Object object)
          Return the path of the specified object relative to this container, or null if the object is not found.
 IDirectory getRoot()
          Return the root of this directory.
protected  IDirectory getSubdirectory(java.lang.String name, boolean create)
          Return the subdirectory with the specified name.
 java.util.Enumeration keys()
          Return an enumeration over all the keys in this directory.
 IDirectory newSubdirectory(java.lang.String name)
          Create and return a new subdirectory with the specified name.
 java.lang.Object peek(java.lang.String path)
          Return the object with the specified path, or null if not found.
 java.lang.Object put(java.lang.String path, java.lang.Object object)
          Associate an object with the specified path.
 java.lang.Object remove(java.lang.String path)
          Remove and return the object associate with the specified path, or null if not found.
 boolean removeObject(java.lang.Object object)
          Remove the specifed object from the directory.
 void setParent(IDirectory directory)
          Set the parent of this directory.
 int size()
          Return the number of entries in this directory.
 java.lang.String toString()
          Return a description of this directory.
protected  java.lang.String toString(java.lang.String type)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dictionary

protected java.util.Dictionary dictionary

parent

protected IDirectory parent
Constructor Detail

Directory

public Directory()
Create an empty Directory with no parent and a Hashtable as its underlying Dictionary.


Directory

public Directory(java.util.Dictionary dictionary)
Create a Directory with no parent and the specified Dictionary as its underlying storage.

Parameters:
dictionary - The dictionary to use as storage.
Method Detail

toString

public java.lang.String toString()
Return a description of this directory.


toString

protected java.lang.String toString(java.lang.String type)
Parameters:
type -

getPath

public java.lang.String getPath(java.lang.Object object)
                         throws DirectoryException
Return the path of the specified object relative to this container, or null if the object is not found.

Specified by:
getPath in interface IContainer
Parameters:
object - The object to find.
Throws:
DirectoryException - If an internal exception occurs.

get

public java.lang.Object get(java.lang.String path)
                     throws DirectoryException
Return the object associated with the the specified path, or null if not found.

Specified by:
get in interface IDirectory
Parameters:
path - The path.
Throws:
DirectoryException - If the path is invalid or an exception occurs in the underlying directory.

peek

public java.lang.Object peek(java.lang.String path)
                      throws DirectoryException
Return the object with the specified path, or null if not found. If the object is lazy loaded by the underlying directory, this operation return null instead of retrieving the object.

Specified by:
peek in interface IDirectory
Parameters:
path - The path.
Throws:
DirectoryException - If an error occurs in the underlying directory.

put

public java.lang.Object put(java.lang.String path,
                            java.lang.Object object)
                     throws DirectoryException
Associate an object with the specified path.

Specified by:
put in interface IDirectory
Parameters:
path - The path.
object - The object.
Throws:
DirectoryException - If the path is invalid or an exception occurs in the underlying directory.

remove

public java.lang.Object remove(java.lang.String path)
                        throws DirectoryException
Remove and return the object associate with the specified path, or null if not found.

Specified by:
remove in interface IDirectory
Parameters:
path - The path.
Throws:
DirectoryException - If the path is invalid or an exception occurs in the underlying directory.

setParent

public void setParent(IDirectory directory)
Set the parent of this directory.

Specified by:
setParent in interface IDirectory
Parameters:
directory - The new parent.

getParent

public IDirectory getParent()
Return the parent of this directory, or null if there is none.

Specified by:
getParent in interface IDirectory

getRoot

public IDirectory getRoot()
Return the root of this directory.

Specified by:
getRoot in interface IDirectory

newSubdirectory

public IDirectory newSubdirectory(java.lang.String name)
                           throws DirectoryException
Create and return a new subdirectory with the specified name.

Specified by:
newSubdirectory in interface IDirectory
Parameters:
name - The name of the new subdirectory.
Throws:
DirectoryException - If the name is invalid or the subdirectory could not be constructed.

delete

public void delete()
            throws DirectoryException
Delete this directory. This operation does not affect the subdirectories.

Specified by:
delete in interface IDirectory
Throws:
DirectoryException - If the directory could not be deleted.

size

public int size()
Return the number of entries in this directory.

Specified by:
size in interface IDirectory

keys

public java.util.Enumeration keys()
Return an enumeration over all the keys in this directory.

Specified by:
keys in interface IDirectory

removeObject

public boolean removeObject(java.lang.Object object)
                     throws DirectoryException
Remove the specifed object from the directory. Return true if the object was found and removed, otherwise return false.

Specified by:
removeObject in interface IDirectory
Parameters:
object - The object to remove.
Throws:
DirectoryException - If an error occurs in the underlying directory.

getParts

protected electric.directory.Parts getParts(java.lang.String path,
                                            boolean create)
                                     throws DirectoryException
Return a Parts object that contains a broken down version of the specified path. If the path contains a subdirectory that does not exist, create it automatically if the create flag is true, otherwise throw an exception.

Parameters:
path - The path to parse.
create - If true, allow a subdirectory to be created on demand.
Throws:
DirectoryException

getSubdirectory

protected IDirectory getSubdirectory(java.lang.String name,
                                     boolean create)
                              throws DirectoryException
Return the subdirectory with the specified name. If the subdirectory does not exist, create it if the create flag is true, otherwise throw an exception

Parameters:
name - The name of the subdirectory.
create - If true, allow the subdirectory to be created on demand.
Throws:
DirectoryException - If the subdirectory could be not created.

findAll

public java.util.Enumeration findAll(ISelector selector)
                              throws DirectoryException
Specified by:
findAll in interface IDirectory
Parameters:
selector -
Throws:
DirectoryException

findFirst

public java.lang.Object findFirst(ISelector selector)
                           throws DirectoryException
Specified by:
findFirst in interface IDirectory
Parameters:
selector -
Throws:
DirectoryException


copyright© 2001-2004 by webMethods All Rights Reserved.