|
DLESE Tools v1.6.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.dlese.dpc.datamgr.DataManager org.dlese.dpc.datamgr.SerializedDataManager org.dlese.dpc.datamgr.SimpleDataStore
public class SimpleDataStore
A Hashtable-like interface for reading and writing persistent Java objects from and to
disc. Same as SerializedDataManager except the getter and setter methods return null insted
of throwing exceptions. Objects are stored in serialized form on disc - any object
that implements Serializable
can be stored in this DataManager for
persistent retrieval. The objects can also be held in a RAM cache to provide faster
retrieval. Serialized objects are stored in a directory specified at the time of
construction. Objects stored in a SimpleDataStore can be of mixed type. This class is
safe to use with multiple process and/or JVMs that access the same dataPath
concurrently.
Field Summary |
---|
Fields inherited from class org.dlese.dpc.datamgr.SerializedDataManager |
---|
codes, dataPath, debug, locks, nextLockKey, num_records, objectCache, useCache, useFileLocks |
Constructor Summary | |
---|---|
SimpleDataStore()
Constructor for the SimpleDataStore object, restores a serialized SimpleDataStore. |
|
SimpleDataStore(String dataPath,
boolean useCache)
Constructs a new SimpleDataStore that reads and writes data to the given dataPath directory. |
Method Summary | |
---|---|
boolean |
delete(String oid)
Deletes an existing data object iff the object is not locked by another user. |
boolean |
delete(String oid,
String lockKey)
Deletes an existing data object, assuming the caller had requested and recieved the necessary lock. |
List |
get(List oids)
Retrieves a List of data objects. |
Object |
get(String oid)
Retrieves a single data object, or null if none exists or unable to retrieve. |
List |
getCopy(List oids)
Retrieves a List of copied data objects, suitable for modifying. |
Object |
getCopy(String oid)
Retrieves a copy of a single data object, sutable for modifying, or null if none exists or unable to retrieve. |
long |
getLastModifiedDate(String oid)
Returns the time that the object denoted by this oid was last modified. |
Object |
put(String oid,
Object obj)
Adds a new object of data, replacing the existing one if one exists and is not locked. |
Object |
put(String oid,
Object obj,
String lockKey)
Adds a new object of data, replacing the existing one if one exists and it can be unlocked with the given key. |
Object |
remove(String oid)
Removes an existing data object iff the object is not locked by another user. |
Object |
remove(String oid,
String lockKey)
Removes an existing data object, assuming the caller had requested and recieved the necessary lock for the object. |
Object |
update(String oid,
Object obj)
Updates a new object of data iff the object is not locked by another user. |
Object |
update(String oid,
Object obj,
String lockKey)
Updates a new object of data, assuming the caller had requested and recieved the necessary lock. |
Methods inherited from class org.dlese.dpc.datamgr.SerializedDataManager |
---|
decodeFileName, encodeFileName, getIDs, getIDsSorted, getLock, getNextLockKey, getNumFiles, getNumRecords, isLocked, isValidLock, lock, oidExists, prtln, releaseLock, restoreSerializedObject, serailizeObject, setDebug, unlock |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SimpleDataStore(String dataPath, boolean useCache) throws Exception
get(String)
and
get(List)
methods are not safe to modify. Specifically, any changes made to
the objects will be reflected in subsequent calls to those methods. To get a copy of
the data items that are safe to modify the caller should use the getCopy(String)
or getCopy(List)
methods instead. If caching is not turned
on, the effect of the get methods are the same as the getCopy methods.This class is safe to use with multiple process and/or JVMs that access the same dataPath.
dataPath
- The directory where the serialzed objects are stored.useCache
- Indicates whether to cache the objects in RAM memory for faster
retrievel.
Exception
- If error.public SimpleDataStore()
Method Detail |
---|
public Object get(String oid)
get(List)
method. To get a copy of a data item that is safe to modify use the
getCopy(String)
method instead. If caching is not enabled, the effect of
this method is the same as getCopy(String)
.
get
in class SerializedDataManager
oid
- The data identifier
Object
of data or null.getCopy(String)
public Object getCopy(String oid)
getCopy
in class SerializedDataManager
oid
- The data identifier.
Object
of data that is in this SimpleDataStore
or null.get(String)
public List get(List oids)
List
of data objects. Note that if caching is turned on in
this SimpleDataStore, the objects that are returned are not safe to modify.
Specifically, if caching is enabled, any changes made to the objects will be
reflected in subsequent calls to this method and the get(String)
method. To
get a copy of a data items that are safe to modify use the getCopy(List)
method instead. If caching is not ebabled, the effect of this method is the same as
getCopy(List)
.
get
in class SerializedDataManager
oids
- List
of data identifiers
List
of corresponding data objectsgetCopy(List)
public List getCopy(List oids)
List
of copied data objects, suitable for modifying. The
objects that are returned are safe for modifying without affecting the data that is
in this SimpleDataStore.
getCopy
in class SerializedDataManager
oids
- List
of data identifiers.
List
of corresponding data objects copies.get(List)
public Object remove(String oid, String lockKey)
remove
in class SerializedDataManager
oid
- The unique identifier that references the data object to be removedlockKey
- The key corresponding to the lock on this data object
public Object remove(String oid)
remove
in class SerializedDataManager
oid
- The unique identifier that references the data object to be removed
public boolean delete(String oid, String lockKey)
remove()
except no object is returned and
thus is more efficient if an object is not required.
delete
in class SerializedDataManager
oid
- The unique identifier that references the data object to be deletedlockKey
- The key corresponding to the lock on this data object
public boolean delete(String oid)
remove()
except no object is returned and thus is more efficient. After successful completion
the object is deleted from the DataManager.
delete
in class SerializedDataManager
oid
- The unique identifier that references the data object to be deleted
public Object put(String oid, Object obj)
put
in class SerializedDataManager
oid
- The unique identifier that references the new data objectobj
- The new data object
public Object put(String oid, Object obj, String lockKey)
oid
- The unique identifier that references the new data objectobj
- The new data objectlockKey
- The key corresponding to the lock on this data object
public Object update(String oid, Object obj, String lockKey)
update
in class SerializedDataManager
oid
- The unique identifier that references the data object to be updatedobj
- The new updated data objectlockKey
- The key corresponding to the lock on this data object
public Object update(String oid, Object obj)
update
in class SerializedDataManager
oid
- The unique identifier that references the data object to be updatedobj
- The new updated data object
public long getLastModifiedDate(String oid)
getLastModifiedDate
in class SerializedDataManager
oid
- The unique identifier that references the data object
|
DLESE Tools v1.6.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |