|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmarf.Storage.StorageManager
public abstract class StorageManager
Class StorageManager provides basic persistence manager.
Almost every concrete module must inherit from this class that manages persistent data.
If that's not possible, implement IStorageManager interface
.
IStorageManager
,
Serialized FormField Summary | |
---|---|
protected boolean |
bDumpOnNotFound
If set to true (the default), causes
restoreBinary() or restoreGzipBinary()
to create a file if it does not exist. |
protected int |
iCurrentDumpMode
Indicates in which format dump training data. |
protected java.io.Serializable |
oObjectToSerialize
Actual object to be serialized (primarily for DUMP_GZIP_BINARY and DUMP_BINARY modes). |
protected java.lang.String |
strFilename
Filename of the file to be dumped/restored. |
Fields inherited from interface marf.Storage.IStorageManager |
---|
DUMP_BINARY, DUMP_CSV_TEXT, DUMP_GZIP_BINARY, DUMP_HTML, DUMP_SQL, DUMP_XML, MARF_INTERFACE_CODE_REVISION, STORAGE_FILE_EXTENSIONS |
Constructor Summary | |
---|---|
StorageManager()
Default constructor equivalent to StorageManager(null, getClass().getName()) . |
|
StorageManager(java.lang.Object poObjectToSerialize)
General constructor with serializable object parameter. |
|
StorageManager(java.lang.Object poObjectToSerialize,
boolean pbDumpOnNotFound)
General constructor with serializable object parameter. |
|
StorageManager(java.lang.Object poObjectToSerialize,
java.lang.String pstrFilename)
General constructor with filename and serializable object parameters. |
|
StorageManager(java.lang.Object poObjectToSerialize,
java.lang.String pstrFilename,
boolean pbDumpOnNotFound)
General constructor with filename and serializable object parameters. |
|
StorageManager(java.io.Serializable poObjectToSerialize)
General constructor with serializable object parameter. |
|
StorageManager(java.io.Serializable poObjectToSerialize,
boolean pbDumpOnNotFound)
General constructor with serializable object parameter. |
|
StorageManager(java.io.Serializable poObjectToSerialize,
java.lang.String pstrFilename)
General constructor with filename and serializable object parameters. |
|
StorageManager(java.io.Serializable poObjectToSerialize,
java.lang.String pstrFilename,
boolean pbDumpOnNotFound)
General constructor with filename and serializable object parameters. |
|
StorageManager(java.lang.String pstrFilename)
Constructor with filename parameter equivalent to StorageManager(null, pstrFilename) . |
|
StorageManager(java.lang.String pstrFilename,
boolean pbDumpOnNotFound)
Constructor with filename parameter equivalent to StorageManager(null, pstrFilename) . |
Method Summary | |
---|---|
void |
backSynchronizeObject()
Must to be overridden by the modules that use object serialization with the generic implementation of restore() . |
java.lang.Object |
clone()
Implements Cloneable for this StorageManager. |
void |
dump()
An object must know how dump itself or its data structures to a file. |
void |
dumpBinary()
Implements object dump in plain binary form without compression. |
void |
dumpCSV()
If derivatives use the generic implementation of dump()
with the CSV dump mode, they must override this method. |
void |
dumpGzipBinary()
Implements object dump in GZIP-compressed form. |
void |
dumpHTML()
If derivatives use the generic implementation of dump()
with the HTML dump mode, they must override this method. |
void |
dumpSQL()
If derivatives use the generic implementation of dump()
with the SQL dump mode, they must override this method. |
void |
dumpXML()
If derivatives use the generic implementation of dump()
with the XML dump mode, they must override this method. |
boolean |
enableDumpOnNotFound(boolean pbEnable)
Enables or disables creation of a file if it does not exist. |
boolean |
equals(java.lang.Object poStorageManager)
Checks equality of two storage managers whether the parameter is not null and its toString() output is equal to this one. |
java.lang.String |
getDefaultExtension()
Retrieves default filename extension of this storage manager. |
static java.lang.String |
getDefaultExtension(int piDumpMode)
Retrieves default filename extension depending on dump type. |
int |
getDumpMode()
Retrieves current dump mode. |
java.lang.String |
getFilename()
Retrieves inner filename reference. |
static java.lang.String |
getMARFSourceCodeRevision()
Returns source code revision information. |
java.io.Serializable |
getObjectToSerialize()
Allows querying for the object this storage manager is in charge of. |
int |
hashCode()
Overrides hashCode() since equals() is overridden by
returning the hash code of the toString() . |
void |
restore()
An object must know how restore itself or its data structures from a file. |
void |
restoreBinary()
Implements object loading from plain binary form without compression. |
void |
restoreCSV()
If derivatives use the generic implementation of restore()
with the CSV dump mode, they must override this method. |
void |
restoreGzipBinary()
Implements object loading from GZIP-compressed binary form. |
void |
restoreHTML()
If derivatives use the generic implementation of restore()
with the HTML dump mode, they must override this method. |
void |
restoreSQL()
If derivatives use the generic implementation of restore()
with the SQL dump mode, they must override this method. |
void |
restoreXML()
If derivatives use the generic implementation of restore()
with the XML dump mode, they must override this method. |
void |
setDumpMode(int piCurrentDumpMode)
Sets the dump mode. |
void |
setFilename(java.lang.String pstrFilename)
Allows to alter inner filename reference. |
java.lang.String |
toString()
Default implementation of the toString() for all storage manager derivatives. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected transient int iCurrentDumpMode
Can either be one of the DUMP_
flags,
with the DUMP_GZIP_BINARY
being the default.
protected transient java.lang.String strFilename
protected java.io.Serializable oObjectToSerialize
backSynchronizeObject()
,
IStorageManager.DUMP_GZIP_BINARY
,
IStorageManager.DUMP_BINARY
protected transient boolean bDumpOnNotFound
true
(the default), causes
restoreBinary()
or restoreGzipBinary()
to create a file if it does not exist. If set to false,
an exception is thrown.
- Since:
- 0.3.0
- See Also:
restoreBinary()
,
restoreGzipBinary()
Constructor Detail
StorageManager
public StorageManager()
- Default constructor equivalent to
StorageManager(null, getClass().getName())
.
Sets internal filename to the class name of the derivative.
- Since:
- 0.3.0.2
- See Also:
StorageManager(Serializable, String)
,
strFilename
StorageManager
public StorageManager(java.lang.String pstrFilename)
- Constructor with filename parameter equivalent to
StorageManager(null, pstrFilename)
.
- Parameters:
pstrFilename
- customized filename- Since:
- 0.3.0.2
- See Also:
StorageManager(Serializable, String)
,
strFilename
StorageManager
public StorageManager(java.lang.Object poObjectToSerialize)
- General constructor with serializable object parameter.
Sets internal filename to the class name of the parameter.
- Parameters:
poObjectToSerialize
- reference to object to be dumped to a file- Since:
- 0.3.0.2
- See Also:
oObjectToSerialize
,
bDumpOnNotFound
StorageManager
public StorageManager(java.io.Serializable poObjectToSerialize)
- General constructor with serializable object parameter.
Sets internal filename to the class name of the parameter.
- Parameters:
poObjectToSerialize
- reference to object to be dumped to a file- Since:
- 0.3.0.6
- See Also:
oObjectToSerialize
,
bDumpOnNotFound
StorageManager
public StorageManager(java.io.Serializable poObjectToSerialize,
java.lang.String pstrFilename)
- General constructor with filename and serializable object parameters.
- Parameters:
poObjectToSerialize
- reference to object to be dumped to a filepstrFilename
- customized filename- Since:
- 0.3.0.6
- See Also:
oObjectToSerialize
,
strFilename
,
bDumpOnNotFound
StorageManager
public StorageManager(java.lang.Object poObjectToSerialize,
java.lang.String pstrFilename)
- General constructor with filename and serializable object parameters.
- Parameters:
poObjectToSerialize
- reference to object to be dumped to a filepstrFilename
- customized filename- Since:
- 0.3.0.2
- See Also:
oObjectToSerialize
,
strFilename
,
bDumpOnNotFound
StorageManager
public StorageManager(java.lang.String pstrFilename,
boolean pbDumpOnNotFound)
- Constructor with filename parameter equivalent to
StorageManager(null, pstrFilename)
.
- Parameters:
pstrFilename
- customized filenamepbDumpOnNotFound
- if true
, a dump file will be created if it does not exist;
if false
, an exception will be thrown- Since:
- 0.3.0.2
- See Also:
StorageManager(Serializable, String)
,
strFilename
StorageManager
public StorageManager(java.lang.Object poObjectToSerialize,
boolean pbDumpOnNotFound)
- General constructor with serializable object parameter.
Sets internal filename to the class name of the parameter.
- Parameters:
poObjectToSerialize
- reference to object to be dumped to a filepbDumpOnNotFound
- if true
, a dump file will be created if it does not exist;
if false
, an exception will be thrown- Since:
- 0.3.0.2
- See Also:
oObjectToSerialize
,
bDumpOnNotFound
StorageManager
public StorageManager(java.io.Serializable poObjectToSerialize,
boolean pbDumpOnNotFound)
- General constructor with serializable object parameter.
Sets internal filename to the class name of the parameter.
- Parameters:
poObjectToSerialize
- reference to object to be dumped to a filepbDumpOnNotFound
- if true
, a dump file will be created if it does not exist;
if false
, an exception will be thrown- Since:
- 0.3.0.6
- See Also:
oObjectToSerialize
,
bDumpOnNotFound
StorageManager
public StorageManager(java.lang.Object poObjectToSerialize,
java.lang.String pstrFilename,
boolean pbDumpOnNotFound)
- General constructor with filename and serializable object parameters.
- Parameters:
poObjectToSerialize
- reference to object to be dumped to a filepstrFilename
- customized filenamepbDumpOnNotFound
- if true
, a dump file will be created if it does not exist;
if false
, an exception will be thrown- Since:
- 0.3.0.2
- See Also:
oObjectToSerialize
,
strFilename
StorageManager
public StorageManager(java.io.Serializable poObjectToSerialize,
java.lang.String pstrFilename,
boolean pbDumpOnNotFound)
- General constructor with filename and serializable object parameters.
- Parameters:
poObjectToSerialize
- reference to object to be dumped to a filepstrFilename
- customized filenamepbDumpOnNotFound
- if true
, a dump file will be created if it does not exist;
if false
, an exception will be thrown- Since:
- 0.3.0.6
- See Also:
oObjectToSerialize
,
strFilename
Method Detail
dump
public void dump()
throws StorageException
- An object must know how dump itself or its data structures to a file.
Options are: Object serialization, XML, CSV, HTML, SQL. Internally, the method
calls all the
dump*()
methods based on the current dump mode.
If the derivatives use only DUMP_GZIP_BINARY
or DUMP_BINARY
modes, the
need not do anything except implementing backSynchronizeObject()
. For the
rest of modes they only have to override a corresponding dump*()
method.
- Specified by:
dump
in interface IStorageManager
- Throws:
StorageException
- if saving to a file for some reason fails or
the dump mode set to an unsupported value- See Also:
IStorageManager.DUMP_GZIP_BINARY
,
IStorageManager.DUMP_BINARY
,
dumpGzipBinary()
,
dumpCSV()
,
dumpBinary()
,
dumpXML()
,
dumpHTML()
,
dumpSQL()
,
backSynchronizeObject()
,
iCurrentDumpMode
dumpGzipBinary
public void dumpGzipBinary()
throws StorageException
- Implements object dump in GZIP-compressed form. Attempts
to save internal object reference to the generated/specified filename
- Specified by:
dumpGzipBinary
in interface IStorageManager
- Throws:
StorageException
- in case of I/O or otherwise error during object dump- Since:
- 0.3.0
- See Also:
oObjectToSerialize
,
strFilename
dumpBinary
public void dumpBinary()
throws StorageException
- Implements object dump in plain binary form without compression. Attempts
to save internal object reference to the generated/specified filename
- Specified by:
dumpBinary
in interface IStorageManager
- Throws:
StorageException
- in case of I/O or otherwise error during object dump- Since:
- 0.3.0
- See Also:
oObjectToSerialize
,
strFilename
dumpCSV
public void dumpCSV()
throws StorageException
- If derivatives use the generic implementation of
dump()
with the CSV dump mode, they must override this method.
- Specified by:
dumpCSV
in interface IStorageManager
- Throws:
NotImplementedException
StorageException,
- declared, but never thrown
StorageException
- in case of I/O or otherwise error- Since:
- 0.3.0
- See Also:
dump()
dumpXML
public void dumpXML()
throws StorageException
- If derivatives use the generic implementation of
dump()
with the XML dump mode, they must override this method.
- Specified by:
dumpXML
in interface IStorageManager
- Throws:
NotImplementedException
StorageException,
- declared, but never thrown
StorageException
- in case of I/O or otherwise error- Since:
- 0.3.0
- See Also:
dump()
dumpHTML
public void dumpHTML()
throws StorageException
- If derivatives use the generic implementation of
dump()
with the HTML dump mode, they must override this method.
- Specified by:
dumpHTML
in interface IStorageManager
- Throws:
NotImplementedException
StorageException,
- declared, but never thrown
StorageException
- in case of I/O or otherwise error- Since:
- 0.3.0
- See Also:
dump()
dumpSQL
public void dumpSQL()
throws StorageException
- If derivatives use the generic implementation of
dump()
with the SQL dump mode, they must override this method.
- Specified by:
dumpSQL
in interface IStorageManager
- Throws:
NotImplementedException
StorageException,
- declared, but never thrown
StorageException
- in case of I/O or otherwise error- Since:
- 0.3.0
- See Also:
dump()
restore
public void restore()
throws StorageException
- An object must know how restore itself or its data structures from a file.
Options are: Object serialization, XML, CSV, HTML, SQL. Internally, the method
calls all the
restore*()
methods based on the current dump mode.
If the derivatives use only DUMP_GZIP_BINARY
or DUMP_BINARY
modes, the
need not do anything except implementing backSynchronizeObject()
. For the
rest of modes they only have to override a corresponding restore*()
method.
- Specified by:
restore
in interface IStorageManager
- Throws:
StorageException
- if loading from a file for some reason fails or
the dump mode set to an unsupported value- See Also:
IStorageManager.DUMP_GZIP_BINARY
,
IStorageManager.DUMP_BINARY
,
dumpGzipBinary()
,
dumpCSV()
,
dumpBinary()
,
dumpXML()
,
dumpHTML()
,
dumpSQL()
,
backSynchronizeObject()
,
iCurrentDumpMode
restoreBinary
public void restoreBinary()
throws StorageException
- Implements object loading from plain binary form without compression. Attempts
to load internal object reference with the generated/specified filename. After,
calls
backSynchronizeObject()
so the actual mode can reset back
references in its own data structures. If the file that we attempt to load
did not exist, it will be created.
- Specified by:
restoreBinary
in interface IStorageManager
- Throws:
StorageException
- in case of I/O or otherwise error during object restoration- Since:
- 0.3.0
- See Also:
backSynchronizeObject()
,
strFilename
restoreGzipBinary
public void restoreGzipBinary()
throws StorageException
- Implements object loading from GZIP-compressed binary form. Attempts
to load internal object reference with the generated/specified filename. After,
calls
backSynchronizeObject()
so the actual mode can reset back
references in its own data structures. If the file that we attempt to load
did not exist, it will be created.
- Specified by:
restoreGzipBinary
in interface IStorageManager
- Throws:
StorageException
- in case of I/O or otherwise error during object restoration- Since:
- 0.3.0
- See Also:
backSynchronizeObject()
,
strFilename
restoreCSV
public void restoreCSV()
throws StorageException
- If derivatives use the generic implementation of
restore()
with the CSV dump mode, they must override this method.
- Specified by:
restoreCSV
in interface IStorageManager
- Throws:
NotImplementedException
StorageException,
- declared, but never thrown
StorageException
- in case of I/O or otherwise error- Since:
- 0.3.0
- See Also:
restore()
restoreXML
public void restoreXML()
throws StorageException
- If derivatives use the generic implementation of
restore()
with the XML dump mode, they must override this method.
- Specified by:
restoreXML
in interface IStorageManager
- Throws:
NotImplementedException
StorageException,
- declared, but never thrown
StorageException
- in case of I/O or otherwise error- Since:
- 0.3.0
- See Also:
restore()
restoreHTML
public void restoreHTML()
throws StorageException
- If derivatives use the generic implementation of
restore()
with the HTML dump mode, they must override this method.
- Specified by:
restoreHTML
in interface IStorageManager
- Throws:
NotImplementedException
StorageException,
- declared, but never thrown
StorageException
- in case of I/O or otherwise error- Since:
- 0.3.0
- See Also:
restore()
restoreSQL
public void restoreSQL()
throws StorageException
- If derivatives use the generic implementation of
restore()
with the SQL dump mode, they must override this method.
- Specified by:
restoreSQL
in interface IStorageManager
- Throws:
NotImplementedException
StorageException,
- declared, but never thrown
StorageException
- in case of I/O or otherwise error- Since:
- 0.3.0
- See Also:
restore()
backSynchronizeObject
public void backSynchronizeObject()
- Must to be overridden by the modules that use object serialization
with the generic implementation of
restore()
. By default
this method is unimplemented.
- Throws:
NotImplementedException
- Since:
- 0.3.0.2
- See Also:
restore()
getObjectToSerialize
public java.io.Serializable getObjectToSerialize()
- Allows querying for the object this storage manager is in charge of.
- Returns:
- the reference to the serializable object
- Since:
- 0.3.0.6
getFilename
public java.lang.String getFilename()
- Retrieves inner filename reference.
- Returns:
- filename string
- Since:
- 0.3.0
setFilename
public void setFilename(java.lang.String pstrFilename)
- Allows to alter inner filename reference.
- Parameters:
pstrFilename
- new filename- Since:
- 0.3.0
getDefaultExtension
public java.lang.String getDefaultExtension()
- Retrieves default filename extension of this storage manager.
- Returns:
- extension String
- Since:
- 0.3.0
getDefaultExtension
public static java.lang.String getDefaultExtension(int piDumpMode)
- Retrieves default filename extension depending on dump type.
- Parameters:
piDumpMode
- dump mode to query extensions map by
- Returns:
- extension String; "unknown" is returned if the parameter
is outside of the range
- Since:
- 0.3.0
getDumpMode
public final int getDumpMode()
- Retrieves current dump mode.
- Returns:
- the mode, integer
- Since:
- 0.3.0
setDumpMode
public final void setDumpMode(int piCurrentDumpMode)
- Sets the dump mode.
- Parameters:
piCurrentDumpMode
- the mode- Since:
- 0.3.0
enableDumpOnNotFound
public final boolean enableDumpOnNotFound(boolean pbEnable)
- Enables or disables creation of a file if it does not exist.
- Parameters:
pbEnable
- new value of the flag
- Returns:
- old value of the flag
- Since:
- 0.3.0
- See Also:
bDumpOnNotFound
clone
public java.lang.Object clone()
- Implements Cloneable for this StorageManager.
The object to serialize is not clone, but rather
its reference is copied by assignment.
- Overrides:
clone
in class java.lang.Object
- Since:
- 0.3.0.5
- See Also:
Object.clone()
equals
public boolean equals(java.lang.Object poStorageManager)
- Checks equality of two storage managers whether
the parameter is not null and its toString() output
is equal to this one.
- Overrides:
equals
in class java.lang.Object
- Since:
- 0.3.0.5
- See Also:
Object.equals(java.lang.Object)
hashCode
public int hashCode()
- Overrides
hashCode()
since equals()
is overridden by
returning the hash code of the toString()
.
- Overrides:
hashCode
in class java.lang.Object
- Since:
- 0.3.0.5
- See Also:
Object.hashCode()
,
equals(Object)
toString
public java.lang.String toString()
- Default implementation of the toString() for all storage
manager derivatives.
- Overrides:
toString
in class java.lang.Object
- Since:
- 0.3.0.5
- See Also:
Object.toString()
getMARFSourceCodeRevision
public static java.lang.String getMARFSourceCodeRevision()
- Returns source code revision information.
- Returns:
- revision string
- Since:
- 0.3.0.2
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD