public class WrappingStorageUtility extends Object implements IStorageUtilityIndexed
| Modifier and Type | Class and Description |
|---|---|
static interface |
WrappingStorageUtility.SerializationWrapper
Defines an alternate serialization scheme.
|
| Constructor and Description |
|---|
WrappingStorageUtility(String name,
WrappingStorageUtility.SerializationWrapper wrapper,
IStorageFactory storageFactory)
Create a new wrapping StorageUtility
|
| Modifier and Type | Method and Description |
|---|---|
int |
add(Externalizable e)
Add a new record to the store.
|
void |
close()
Close all resources associated with this StorageUtility.
|
void |
destroy()
Delete the storage utility itself, along with all stored records and meta-data
|
boolean |
exists(int id)
Return whether a record exists in the store
|
Object |
getAccessLock()
Fetch the object that acts as the synchronization lock for this StorageUtility
|
List<Integer> |
getIDsForValue(String fieldName,
Object value)
Retrieves a List of IDs of Externalizable objects in storage for which the field
specified contains the value specified.
|
int |
getNumRecords()
Return the number of records in the store
|
Externalizable |
getRecordForValue(String fieldName,
Object value)
Retrieves a Externalizable object from the storage which is reference by the unique index fieldName.
|
int |
getRecordSize(int id)
Get the size of a record
|
int |
getTotalSize()
Return total size of device storage consumed by this StorageUtility
|
boolean |
isEmpty()
Return whether the store is empty
|
IStorageIterator |
iterate()
Return an iterator to iterate through all records in this store
|
Externalizable |
read(int id)
Read and return the record corresponding to 'id'.
|
byte[] |
readBytes(int id)
Read and return the raw bytes for the record corresponding to 'id'.
|
void |
registerIndex(String filterIndex)
Optional.
|
void |
remove(int id)
Remove record with the given ID from the store.
|
void |
remove(Persistable p)
Remove object from the store
|
void |
removeAll() |
List<Integer> |
removeAll(EntityFilter ef) |
void |
repack()
Perform any clean-up/consolidation of the StorageUtility's underlying datastructures that is too expensive to do during
normal usage (e.g., if all the records are scattered among 10 half-empty RMSes, repack them into 5 full RMSes)
|
void |
repair()
If the StorageUtility has been left in a corrupt/inconsistent state, restore it to a non-corrupt state, even if it results
in data loss.
|
void |
setReadOnly() |
void |
update(int id,
Externalizable e)
Update a record in the store.
|
void |
write(Persistable p)
Write an object to the store.
|
public WrappingStorageUtility(String name, WrappingStorageUtility.SerializationWrapper wrapper, IStorageFactory storageFactory)
name - unique name for underlying StorageUtilitywrapper - serialization wrapperstorageFactory - factory to create underlying StorageUtilitypublic Externalizable read(int id)
IStorageUtilityread in interface IStorageUtilityid - id of the objectpublic void write(Persistable p) throws StorageFullException
IStorageUtilitywrite in interface IStorageUtilityp - object to storeStorageFullException - if there is not enough room to store the objectpublic int add(Externalizable e) throws StorageFullException
IStorageUtilityadd in interface IStorageUtilitye - object to addStorageFullException - if not enough space availablepublic void update(int id,
Externalizable e)
throws StorageFullException
IStorageUtilityupdate in interface IStorageUtilityid - ID of record to updatee - updated objectStorageFullException - if not enough space available to updatepublic IStorageIterator iterate()
IStorageUtilityiterate in interface IStorageUtilitypublic byte[] readBytes(int id)
IStorageUtilityreadBytes in interface IStorageUtilityid - id of the objectpublic void remove(int id)
IStorageUtilityremove in interface IStorageUtilityid - ID of record to removepublic void remove(Persistable p)
IStorageUtilityremove in interface IStorageUtilityp - object to removepublic void removeAll()
removeAll in interface IStorageUtilitypublic List<Integer> removeAll(EntityFilter ef)
removeAll in interface IStorageUtilitypublic boolean exists(int id)
IStorageUtilityexists in interface IStorageUtilityid - record IDpublic boolean isEmpty()
IStorageUtilityisEmpty in interface IStorageUtilitypublic int getNumRecords()
IStorageUtilitygetNumRecords in interface IStorageUtilitypublic int getRecordSize(int id)
IStorageUtilitygetRecordSize in interface IStorageUtilityid - record IDpublic int getTotalSize()
IStorageUtilitygetTotalSize in interface IStorageUtilitypublic void close()
IStorageUtilityclose in interface IStorageUtilitypublic void destroy()
IStorageUtilitydestroy in interface IStorageUtilitypublic void repack()
IStorageUtilityrepack in interface IStorageUtilitypublic void repair()
IStorageUtilityrepair in interface IStorageUtilitypublic Object getAccessLock()
IStorageUtilitygetAccessLock in interface IStorageUtilitypublic List<Integer> getIDsForValue(String fieldName, Object value)
IStorageUtilityIndexedgetIDsForValue in interface IStorageUtilityIndexedfieldName - The name of a field which should be evaluatedvalue - The value which should be contained by the field specifiedpublic Externalizable getRecordForValue(String fieldName, Object value) throws NoSuchElementException, InvalidIndexException
IStorageUtilityIndexedgetRecordForValue in interface IStorageUtilityIndexedfieldName - The name of the index field which will be evaluatedvalue - The value which should be set in the index specified by fieldName for the returned
object.NoSuchElementException - If no objects reside in storage for which the return condition
can be successful.InvalidIndexException - If the field used is an invalid index, because more than one field in the Storage
contains the value of the index requested.public void setReadOnly()
setReadOnly in interface IStorageUtilitypublic void registerIndex(String filterIndex)
IStorageUtilityIndexedregisterIndex in interface IStorageUtilityIndexedCopyright © 2024. All rights reserved.