|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.Dictionary | +--com.sas.edir.content.FileManager
The File Manager gives a java.util.Dictionary access to the file system. Objects (java.io.InputStream, java.io.Reader, or java.io.Serializable) are added into the FileManager based on a Serializable Key, FileManager.Key. Objects (java.io.InputStream, java.io.Reader, or java.io.Serializable) are retrieved from the FileManager based on the FileManager.Key. Two FileManager.Key objects are equal (by default) if their user (getUser()) and their uid (getUID()) fields are equal. This can be redefined on a per FileManager.Key extension. The actual storage of the data is done through a protected class, FileManager.Storage. There is one Storage class per user. (obtained from the FileManager.Key information) Given a FileManager.Key, the FileManager.Storage class generates a unique key and writes/reads the file from the file system using it's unique key. The FileManager.Key class must be serializable in order for the Storage class to write it's FileManager.Key/Storage class key mapping state to the file system. In addition to the java.util.Dictionary methods, FileManager provides public Enumeration clear() public Enumeration clear(Object key) public Enumeration keys(Object key) public Enumeration elements(Object key) public Enumeration users() public long getUsage(Object key) public long setQuota(Object key, long quota) public long getQuota(Object key) public long getUsage() public File getFile(Object key) public int getGarbageCollectionInterval() public int setGarbageCollectionInterval(int secs) public void gc() public int setReadBufferSize(int size) public int getReadBufferSize() public int setUserStackSize(int size) public int getUserStackSize() in order to aid in System Administration.
Inner Class Summary | |
static class |
FileManager.DefaultKey
Default key. |
protected static class |
FileManager.GarbageCollector
The GarbageCollector's resposibility is to lazily enumerate the Storage object's keys and check for expiration. |
static class |
FileManager.Key
This is the abstract class that all keys must extend in order to store content in the FileManager. |
protected static class |
FileManager.Link
Link extends java.io.File and provides a "first-line" defense that discourages inadvertant modifications. |
protected static class |
FileManager.Storage
The Storage class provides java.util.Dictionary access to the file system for the File Manager. |
Field Summary | |
static java.lang.String |
ROOT
Storage designated for the root location of the File Manager |
static long |
UNLIMITED
The default Quota assigned to a user |
Method Summary | |
protected FileManager.Storage |
borrowStorage(java.lang.Object key)
Checks out and returns a Storage Object based on the specified key |
java.util.Enumeration |
clear()
Clears this File Manager so that it contains no keys. |
java.util.Enumeration |
clear(java.lang.Object key)
Clears this FileManager so that it contains no keys for a particular user. |
static FileManager.Key |
createDefaultKey(java.lang.String path)
Returns a new DefaultKey based on a path. |
static FileManager.Key |
createDefaultKey(java.lang.String user,
java.lang.Object uid)
Returns a new DefaultKey based on a user and a unique id A null or FileManager.ROOT user will store the data associated with this key in the root directory of the FileManager. |
protected FileManager.GarbageCollector |
createGarbageCollector()
Creates the garbage collector for this instance. |
protected java.lang.Integer |
createReadBufferSize()
Creates the read buffer size either from serialized data or default 512 This value is serialized to/from the FileManager.ROOT |
protected java.lang.Integer |
createUserStackSize()
Creates the user stack size either from serialized data or default 200 This value is serialized to/from the FileManager.ROOT |
java.util.Enumeration |
elements()
Returns an enumeration of the values in this dictionary. |
java.util.Enumeration |
elements(java.lang.Object key)
Returns an enumeration of the values in this dictionary for a particular user. |
void |
gc()
Manually run the garbage collector to collect expired keys |
java.lang.Object |
get(java.lang.Object key)
Returns the value to which the key is mapped in this dictionary. |
java.io.File |
getDirectory()
Returns the java.io.File that is the location of the File Manager. |
java.io.File |
getFile()
Returns the java.io.File that is the fully qualified name of the File Manager. |
java.io.File |
getFile(java.lang.Object key)
Returns a FileManager.Link based on a FileManager.Key. |
int |
getGarbageCollectionInterval()
Gets the garbage collection interval of expired keys in seconds |
protected FileManager.GarbageCollector |
getGarbageCollector()
Gets the garbage collector for this instance. |
static FileManager |
getInstance()
Returns the single instance of this class. |
protected FileManager.Key |
getKey(java.lang.Object key)
Returns a Key based on the specified key. |
java.lang.String |
getName()
Returns the name of the File Manager |
long |
getQuota(java.lang.Object key)
Gets the quota in bytes for a particular user in the File Manager. |
int |
getReadBufferSize()
Gets the read buffer size for Stream/Reader IO. |
protected int |
getType(java.lang.Object object)
Types of Objects the File Manager can store. |
long |
getUsage()
Returns usage in bytes of the File Manager. |
long |
getUsage(java.lang.Object key)
Returns usage in bytes of a particular user in the File Manager. |
int |
getUserStackSize()
Gets the user stack size to maintain in memory. |
protected boolean |
isAvailable(FileManager.Storage storage)
Returns the availablilty of a Storage Object based on the specified storage |
protected boolean |
isAvailable(java.lang.Object key)
Returns the availablilty of a Storage Object based on the specified key |
boolean |
isEmpty()
Tests if this dictionary maps no keys to value. |
java.util.Enumeration |
keys()
Returns an enumeration of the keys in this dictionary. |
java.util.Enumeration |
keys(java.lang.Object key)
Returns an enumeration of the keys in this dictionary for a particular user. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Maps the specified key to the specified
value in this dictionary. |
java.lang.Object |
remove(java.lang.Object key)
Removes the key (and its corresponding
value ) from this dictionary. |
protected void |
returnStorage(FileManager.Storage storage)
Returns a Storage Object to the pool |
void |
save(java.lang.Object key)
|
protected FileManager.GarbageCollector |
saveGarbageCollector()
Saves the garbage collector for this instance. |
protected java.lang.Integer |
saveReadBufferSize()
Saves the read buffer size. |
protected java.lang.Integer |
saveUserStackSize()
Saves the user stack size. |
void |
setDebugStream(java.io.PrintStream debugStream)
|
int |
setGarbageCollectionInterval(int secs)
Sets the garbage collection interval of expired keys in seconds |
void |
setLocation(java.lang.String location)
|
void |
setName(java.lang.String name)
|
long |
setQuota(java.lang.Object key,
long quota)
Sets the quota in bytes for a particular user in the File Manager. |
int |
setReadBufferSize(int size)
Sets the read buffer size for Stream/Reader IO. |
int |
setUserStackSize(int size)
Sets the user stack size to maintain in memory. |
int |
size()
Returns the number of keys in this dictionary. |
void |
start()
|
java.util.Enumeration |
users()
Returns an enumeration of the users in this dictionary. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static java.lang.String ROOT
public static long UNLIMITED
Method Detail |
public static FileManager.Key createDefaultKey(java.lang.String user, java.lang.Object uid)
public static FileManager.Key createDefaultKey(java.lang.String path)
public static final FileManager getInstance()
public void setDebugStream(java.io.PrintStream debugStream)
public java.io.File getDirectory()
public void setLocation(java.lang.String location)
public java.lang.String getName()
public void setName(java.lang.String name)
public java.io.File getFile()
public void start()
public java.util.Enumeration elements()
elements
in class java.util.Dictionary
Dictionary.keys()
,
Enumeration
public java.lang.Object get(java.lang.Object key)
get
in class java.util.Dictionary
key
- a key in this dictionary.
null
if the key is not mapped to any value in
this dictionary.If key is not a FileManager.Key (!(key instanceof FileManager.Key))
then a FileManager.DefaultKey will be created using key as the UID
public boolean isEmpty()
isEmpty
in class java.util.Dictionary
true
if this dictionary maps no keys to values;
false
otherwise.public java.util.Enumeration keys()
keys
in class java.util.Dictionary
Dictionary.elements()
,
Enumeration
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
key
to the specified
value
in this dictionary. Neither the key nor the
value can be null
.
The value
can be retrieved by calling the
get
method with a key
that is equal to
the original key
.
put
in class java.util.Dictionary
key
- the hashtable key.value
- the value. One of java.io.InputStream, java.io.Reader, java.io.Serializablekey
was mapped
in this dictionary, or null
if the key did not
have a previous mapping.java.lang.NullPointerException
- if the key
or
value
is null
.
RuntimeException if the user's quota has been exceeded.Object.equals(java.lang.Object)
,
If key is not a FileManager.Key (!(key instanceof FileManager.Key))
then a FileManager.DefaultKey will be created using key as the UID
public java.lang.Object remove(java.lang.Object key)
key
(and its corresponding
value
) from this dictionary. This method does nothing
if the key
is not in this dictionary.remove
in class java.util.Dictionary
key
- the key that needs to be removed.key
had been mapped in this
dictionary, or null
if the key did not have a
mapping.
If key is not a FileManager.Key (!(key instanceof FileManager.Key))
then a FileManager.DefaultKey will be created using key as the UID
The key is notified of the removal by FileManager.Key.delete()
If FileManager.Key.delete() throws an Exception, the key and data will
not be removed.public void save(java.lang.Object key)
public int size()
size
in class java.util.Dictionary
public java.util.Enumeration clear()
public java.util.Enumeration clear(java.lang.Object key)
public java.util.Enumeration keys(java.lang.Object key)
public java.util.Enumeration elements(java.lang.Object key)
public java.util.Enumeration users()
public long getUsage(java.lang.Object key)
public long setQuota(java.lang.Object key, long quota)
public long getQuota(java.lang.Object key)
public long getUsage()
public java.io.File getFile(java.lang.Object key)
public int getGarbageCollectionInterval()
public int setGarbageCollectionInterval(int secs)
public void gc()
public int setReadBufferSize(int size)
public int getReadBufferSize()
public int setUserStackSize(int size)
public int getUserStackSize()
protected java.lang.Integer createUserStackSize()
protected java.lang.Integer saveUserStackSize()
protected java.lang.Integer createReadBufferSize()
protected java.lang.Integer saveReadBufferSize()
protected FileManager.GarbageCollector getGarbageCollector()
protected FileManager.GarbageCollector createGarbageCollector()
protected FileManager.GarbageCollector saveGarbageCollector()
protected int getType(java.lang.Object object)
protected FileManager.Key getKey(java.lang.Object key)
protected FileManager.Storage borrowStorage(java.lang.Object key)
protected void returnStorage(FileManager.Storage storage)
protected boolean isAvailable(java.lang.Object key)
protected boolean isAvailable(FileManager.Storage storage)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |