public class VirtualDataManager extends Object
VirtualDataManager is responsible for holding references to the
serialized files where the content is stored.
Instances can query this class in order to obtain the location of an
IqmDataBox on the disk, when the application is in virtual state.
This is the central instance when dealing with virtual items. This class uses
an instance of Serializer to perform its I/O tasks.
| Modifier and Type | Field and Description |
|---|---|
private HashMap<UUID,File> |
boxCache
A cache of all serialized items.
|
private static org.apache.log4j.Logger |
logger
Custom class logger.
|
private Serializer |
serializer
A serializer for I/O tasks of the manager.
|
| Modifier | Constructor and Description |
|---|---|
private |
VirtualDataManager()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearCache()
This method clears the entire virtual box cache.
|
void |
delete(IVirtualizable target)
Deletes the virtual object from the disk and removes it from the box
cache.
|
static VirtualDataManager |
getInstance() |
static File |
getNewVirtualDirectory()
This method creates a new sub-directory (name) within the temporary
directory specified by
ConfigManager.getTempPath() of the current
ConfigManager instance. |
static File |
getNewVirtualFileName(File dir,
int n)
This method gets a new file name with number
n. |
static File |
getRandomVirtualFileName(File dir)
This method creates a new temporary file name within the specified
directory.
|
Serializer |
getSerializer() |
IqmDataBox |
load(IVirtualizable target)
Load a data item from the serialized state on the hard disk to the
memory.
|
static void |
main(String[] args) |
IVirtualizable |
save(IqmDataBox target,
File directory)
Save a
IVirtualizable object to its specified target and puts the
file location to the cache. |
List<IqmDataBox> |
save(List<IqmDataBox> list,
File directory)
Saves an entire list of
IqmDataBoxes to the temporary directory. |
private static final org.apache.log4j.Logger logger
private Serializer serializer
public Serializer getSerializer()
public static VirtualDataManager getInstance()
public static File getNewVirtualDirectory()
ConfigManager.getTempPath() of the current
ConfigManager instance. Note that the directory will not yet be created on the hard drive!
File the location of the sub-directorypublic static File getNewVirtualFileName(File dir, int n)
n.
Note that the new file will not yet be created on the hard drive!
dir - - the directoryn - - the number to be searched forFile, containing the name for a
IVirtualizable object in a directorypublic static File getRandomVirtualFileName(File dir)
Note that the file will not yet be created on the hard drive!
dir - some directory for the virtual filepublic IVirtualizable save(IqmDataBox target, File directory)
IVirtualizable object to its specified target and puts the
file location to the cache.target - the target to be saved, e.g. an IqmDataBoxdirectory - the directory, where the target is being saved (must
already exist!)VirtualDataBox) if
successful, or null otherwiseIllegalArgumentException - if one of the parameters is null or the directory does not
existpublic IqmDataBox load(IVirtualizable target)
target - the target to be loadedIqmDataBox containing the data models, or
null, if no item is associated with the targetIllegalArgumentException - if the parameter is nullpublic void delete(IVirtualizable target)
target - the object to be deletedIllegalArgumentException - if one of the parameters is nullpublic void clearCache()
CAUTION: Any objects associated with keys in the cache cannot be located afterwards!
public List<IqmDataBox> save(List<IqmDataBox> list, File directory)
IqmDataBoxes to the temporary directory.list - the list of boxes to be saveddirectory - the directory, where the target is being saved (must
already exist!)null otherwiseIllegalArgumentException - if one of the parameters is null, the list is empty or the
directory does not existpublic static void main(String[] args) throws IOException
IOExceptionCopyright © 2009–2017 Helmut Ahammer, Philipp Kainz. All rights reserved.