public class Storage extends Object
Constructor and Description |
---|
Storage() |
Modifier and Type | Method and Description |
---|---|
void |
clearCache()
Storage is cached for faster access, however this might cause a problem with refreshing
objects since they are not cloned.
|
void |
clearStorage()
Deletes all the files in the application storage
|
InputStream |
createInputStream(String name)
Creates an input stream to the given storage source file
|
OutputStream |
createOutputStream(String name)
Creates an output stream to the storage with the given name
|
void |
deleteStorageFile(String name)
Deletes the given file name from the storage
|
int |
entrySize(String name)
Returns the size in bytes of the given entry
|
boolean |
exists(String name)
Returns true if the given storage file exists
|
void |
flushStorageCache()
Flush the storage cache allowing implementations that cache storage objects
to store
|
static Storage |
getInstance()
Returns the storage instance or null if the storage wasn't initialized using
a call to init(String) first.
|
static boolean |
isInitialized()
Returns true if the storage is initialized
|
boolean |
isNormalizeNames()
Indicates whether characters that are typically illegal in filesystems should
be sanitized and replaced with underscore
|
String[] |
listEntries()
Lists the names of the storage files
|
Object |
readObject(String name)
Reads the object from the storage, returns null if the object isn't there
|
void |
setHardCacheSize(int size)
Indicates the caching size, storage can be pretty slow
|
void |
setNormalizeNames(boolean normalizeNames)
Indicates whether characters that are typically illegal in filesystems should
be sanitized and replaced with underscore
|
boolean |
writeObject(String name,
Object o)
Writes the given object to storage assuming it is an externalizable type
or one of the supported types
|
public void setHardCacheSize(int size)
size
- size in elements (not kb!)public static boolean isInitialized()
public static Storage getInstance()
public void clearCache()
public void flushStorageCache()
public void deleteStorageFile(String name)
name
- the name of the storage filepublic void clearStorage()
public OutputStream createOutputStream(String name) throws IOException
name
- the storage file nameIOException
public InputStream createInputStream(String name) throws IOException
name
- the name of the source fileIOException
public boolean exists(String name)
name
- the storage file namepublic String[] listEntries()
public int entrySize(String name)
name
- the name of the entrypublic boolean writeObject(String name, Object o)
name
- store nameo
- object to storepublic Object readObject(String name)
name
- name of the storepublic boolean isNormalizeNames()
public void setNormalizeNames(boolean normalizeNames)
normalizeNames
- the normalizeNames to set