public class SettingMemory extends java.lang.Object implements Memorizable, java.io.Closeable
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
filename |
protected java.nio.channels.FileLock |
lock |
protected java.io.RandomAccessFile |
raf |
protected java.util.HashMap<java.lang.String,java.lang.String> |
stringProperties |
Constructor and Description |
---|
SettingMemory()
Constructor with default filename, which is java.io.tmpdir / settings.ser.
|
SettingMemory(java.lang.String filename)
Constructor with filename.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
MemorizerPackage |
getMemorizerPackage()
This method creates a MemorizerPackage instance that can be sent in turn to the TemporaryMemorizer instance for serialization.
|
boolean |
getProperty(java.lang.String property,
boolean defaultValue)
This method returns a previously saved property or a default value if
the property has not been set yet.
|
double |
getProperty(java.lang.String property,
double defaultValue)
This method returns a previously saved property or a default value if
the property has not been set yet.
|
int |
getProperty(java.lang.String property,
int defaultValue)
This method returns a previously saved property or a default value if
the property has not been set yet.
|
java.lang.String |
getProperty(java.lang.String property,
java.lang.String defaultValue)
This method returns a previously saved property or a default value if
the property has not been set yet.
|
java.util.Map<java.lang.String,java.lang.String> |
getStringProperties()
This method returns the Map of properties.
|
protected void |
loadSettings()
This method deserializes the settings.
|
protected void |
saveSettings()
This method serializes the settings in the file denoted by the filename
variable.
|
void |
setProperty(java.lang.String property,
boolean value)
This method set a particular property.
|
void |
setProperty(java.lang.String property,
double value)
This method set a particular property.
|
void |
setProperty(java.lang.String property,
int value)
This method set a particular property.
|
void |
setProperty(java.lang.String property,
java.lang.String value)
This method set a particular property.
|
void |
unpackMemorizerPackage(MemorizerPackage wasMemorized)
This method unpacks the MemorizerPackage instance retrieved by the TemporaryMemorizer class.
|
protected java.lang.String filename
protected java.util.HashMap<java.lang.String,java.lang.String> stringProperties
protected java.io.RandomAccessFile raf
protected java.nio.channels.FileLock lock
public SettingMemory()
public SettingMemory(java.lang.String filename)
filename
- the file in which the settings are serializedprotected void saveSettings()
protected void loadSettings()
public java.util.Map<java.lang.String,java.lang.String> getStringProperties()
public void setProperty(java.lang.String property, java.lang.String value)
property
- a Stringvalue
- a Stringpublic void setProperty(java.lang.String property, double value)
property
- a Stringvalue
- a Doublepublic void setProperty(java.lang.String property, boolean value)
property
- a Stringvalue
- a Booleanpublic void setProperty(java.lang.String property, int value)
property
- a Stringvalue
- an Integerpublic java.lang.String getProperty(java.lang.String property, java.lang.String defaultValue)
property
- the property namedefaultValue
- the default value of the propertypublic double getProperty(java.lang.String property, double defaultValue)
property
- the property namedefaultValue
- the default value of the propertypublic boolean getProperty(java.lang.String property, boolean defaultValue)
property
- the property namedefaultValue
- the default value of the propertypublic int getProperty(java.lang.String property, int defaultValue)
property
- the property namedefaultValue
- the default value of the propertypublic final MemorizerPackage getMemorizerPackage()
Memorizable
getMemorizerPackage
in interface Memorizable
public final void unpackMemorizerPackage(MemorizerPackage wasMemorized)
Memorizable
unpackMemorizerPackage
in interface Memorizable
wasMemorized
- a MemorizerPackage instancepublic void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException