public class PropertiesManager
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
configFilePath
The config file's absolute path
|
private java.util.Properties |
defaultProperties
The default properties are saved when the properties file is created.
|
private java.lang.String |
header
The configuration file's header
|
private java.util.Properties |
properties
A variable list of settings defined by the game's options dialog and menu
bar.
|
Constructor and Description |
---|
PropertiesManager() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getProperty(java.lang.String key)
Provides the value of a property's key
|
void |
loadProperties()
Reads the properties from file.
|
private boolean |
makeConfigFile()
Creates the configuration directory and file in the
configuration directory
if it not already exists.
|
void |
saveProperties()
The method is called by the game's option dialog and menu bar forwarding
to
saveProperties(Properties) set its
parabeter to null . |
void |
saveProperties(java.util.Properties prop)
Saves the used
properties list as XML to configFilePath |
void |
setProperty(java.lang.String key,
java.lang.String value)
Adds a key-value-pair to the actual properties.
|
private final java.lang.String configFilePath
private final java.lang.String header
private final java.util.Properties defaultProperties
SudokuConstants
and may be changed by the game's options dialog and menu
bar.properties
private java.util.Properties properties
defaultProperties
are loaded.private boolean makeConfigFile()
true
if the configuration directory and file already
exists or is created successfully otherwise false
.public void saveProperties()
saveProperties(Properties)
set its
parabeter to null
. The properties list usually is defined by
the user and read from configuration file.public void saveProperties(java.util.Properties prop)
properties
list as XML to configFilePath
prop
- the properties object that has to be saved. If
prop
is null
all the actually used
properties object
is saved.public void loadProperties()
defaultProperties
are used for the game and saved to a newly
created config file.public void setProperty(java.lang.String key, java.lang.String value)
key
- String
, the keyvalue
- String
, the valuepublic java.lang.String getProperty(java.lang.String key)
key
- String
the keyString
, the value belonging to key
.