Package adams.core
Class SerializableObjectHelper
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.SerializableObjectHelper
-
- All Implemented Interfaces:
Destroyable
,LoggingLevelHandler
,LoggingSupporter
,SizeOfHandler
,Serializable
public class SerializableObjectHelper extends CustomLoggingLevelObject implements Destroyable
Helper class for serializing an object's member variables.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected SerializableObject
m_Owner
the owner.protected boolean
m_SetupLoadedOrGenerated
whether the setup got loaded or generated already.protected boolean
m_Strict
whether to enforce strict option checks (ie rebuild if different) or just warn.-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description SerializableObjectHelper(SerializableObject owner)
Initializes the helper.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
Frees up memory in a "destructive" non-reversible way.void
generateSetup()
Forces the owner to regenerate all objects that are necessary for serialization.protected String
getCommandLine(Object obj)
Obtains the command-line for the object.SerializableObject
getOwner()
Returns the owning object.boolean
isSetupLoadedOrGenerated()
Returns whether the setup was loaded/generated.boolean
isStrict()
Returns whether to use strict mode (options HAVE to be the same) or not (simple warning then).void
loadSetup()
Attempts to load the setup.void
reset()
Resets the helper, i.e., it will attempt to load the setup again.void
saveSetup()
Saves the owner's member variables to the specified file (ignored if pointing to a directory).void
setSetupLoadedOrGenerated(boolean value)
Sets whether the setup was loaded/generated.void
setStrict(boolean value)
Sets whether to use strict mode (options HAVE to be the same) or not (simply output warning that options changed).String
toString()
Generates some information.-
Methods inherited from class adams.core.logging.CustomLoggingLevelObject
setLoggingLevel
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
m_Owner
protected SerializableObject m_Owner
the owner.
-
m_SetupLoadedOrGenerated
protected boolean m_SetupLoadedOrGenerated
whether the setup got loaded or generated already.
-
m_Strict
protected boolean m_Strict
whether to enforce strict option checks (ie rebuild if different) or just warn.
-
-
Constructor Detail
-
SerializableObjectHelper
public SerializableObjectHelper(SerializableObject owner)
Initializes the helper.- Parameters:
owner
- the owning object
-
-
Method Detail
-
getOwner
public SerializableObject getOwner()
Returns the owning object.- Returns:
- the owner this helper belongs to
-
reset
public void reset()
Resets the helper, i.e., it will attempt to load the setup again.
-
setStrict
public void setStrict(boolean value)
Sets whether to use strict mode (options HAVE to be the same) or not (simply output warning that options changed).- Parameters:
value
- whether options have changed
-
isStrict
public boolean isStrict()
Returns whether to use strict mode (options HAVE to be the same) or not (simple warning then).
-
getCommandLine
protected String getCommandLine(Object obj)
Obtains the command-line for the object.- Parameters:
obj
- the object to get the command-line for- Returns:
- the command-line
-
loadSetup
public void loadSetup()
Attempts to load the setup. If the serialization file object is pointing to a directory or the override flag is set in the owner, then the deserialization from file will be skipped and a fresh setup generated instead. After the new setup has been generated, the data is serialized only if the serialization file is to pointing to an actual file.
-
saveSetup
public void saveSetup()
Saves the owner's member variables to the specified file (ignored if pointing to a directory).
-
generateSetup
public void generateSetup()
Forces the owner to regenerate all objects that are necessary for serialization.
-
setSetupLoadedOrGenerated
public void setSetupLoadedOrGenerated(boolean value)
Sets whether the setup was loaded/generated.- Parameters:
value
- true if loaded/generated
-
isSetupLoadedOrGenerated
public boolean isSetupLoadedOrGenerated()
Returns whether the setup was loaded/generated.- Returns:
- true if loaded/generated
-
toString
public String toString()
Generates some information.
-
destroy
public void destroy()
Frees up memory in a "destructive" non-reversible way.- Specified by:
destroy
in interfaceDestroyable
-
-