Crossfire JXClient, Trunk  R20561
com.realtime.crossfire.jxclient.settings.Settings Class Reference

Maintains a set of key/value pairs. More...

+ Collaboration diagram for com.realtime.crossfire.jxclient.settings.Settings:

Public Member Functions

boolean getBoolean (@NotNull final SettingsEntry< Boolean > key)
 Returns the boolean associated with the specified key at a node or. More...
 
int getInt (@NotNull final SettingsEntry< Integer > key)
 Returns the integer associated with the specified key at a node or. More...
 
long getLong (@NotNull final SettingsEntry< Long > key)
 Returns the long associated with the specified key at a node or. More...
 
String getString (@NotNull final SettingsEntry<?> key)
 Returns the string associated with the specified key at a node, or. More...
 
void putBoolean (@NotNull final SettingsEntry< Boolean > key, final boolean value)
 Stores a key/value pair. More...
 
void putInt (@NotNull final SettingsEntry< Integer > key, final int value)
 Stores a key/value pair. More...
 
void putLong (@NotNull final SettingsEntry< Long > key, final long value)
 Stores a key/value pair. More...
 
void putString (@NotNull final SettingsEntry<?> key, @NotNull final String value)
 Stores a key/value pair. More...
 
void remove (@NotNull final String key)
 Removes a key. More...
 
 Settings (@NotNull final File file)
 Creates a new instance. More...
 

Private Member Functions

void loadValues ()
 Loads the values from the backing file. More...
 
void loadValues (@NotNull final LineNumberReader lnr) throws IOException
 Loads the values. More...
 
void saveValues () throws IOException
 Saves the values to the backing file. More...
 
void setChanged ()
 This function is called whenever the contents of values has changed. More...
 

Static Private Member Functions

static void saveNode (@NotNull final BufferedWriter writer, @NotNull final Map< String, Entry > node) throws IOException
 Saves one node. More...
 

Private Attributes

final File file
 The file for loading/saving values. More...
 
boolean noSave = true
 Flag to inhibit saving. More...
 
final Map< String, Entryvalues = new TreeMap<>()
 The stored values. More...
 

Detailed Description

Maintains a set of key/value pairs.

The values are stored in a flat file.

Author
Andreas Kirschbaum

Definition at line 43 of file Settings.java.

Constructor & Destructor Documentation

◆ Settings()

com.realtime.crossfire.jxclient.settings.Settings.Settings ( @NotNull final File  file)

Creates a new instance.

Parameters
filethe file for loading/saving values

Definition at line 66 of file Settings.java.

References com.realtime.crossfire.jxclient.settings.Settings.file, and com.realtime.crossfire.jxclient.settings.Settings.loadValues().

+ Here is the call graph for this function:

Member Function Documentation

◆ getBoolean()

boolean com.realtime.crossfire.jxclient.settings.Settings.getBoolean ( @NotNull final SettingsEntry< Boolean >  key)

Returns the boolean associated with the specified key at a node or.

defaultValue

if there is no association for this key.

Parameters
keythe key to get the value for
Returns
the value

Definition at line 90 of file Settings.java.

References com.realtime.crossfire.jxclient.settings.Settings.getString().

Referenced by com.realtime.crossfire.jxclient.main.JXClient.JXClient(), and com.realtime.crossfire.jxclient.settings.options.OptionManager.loadOptions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInt()

int com.realtime.crossfire.jxclient.settings.Settings.getInt ( @NotNull final SettingsEntry< Integer >  key)

Returns the integer associated with the specified key at a node or.

defaultValue

if there is no association for this key.

Parameters
keythe key to get the value for
Returns
the value

Definition at line 105 of file Settings.java.

References com.realtime.crossfire.jxclient.settings.Settings.getString(), and com.realtime.crossfire.jxclient.util.NumberParser.parseInt().

+ Here is the call graph for this function:

◆ getLong()

long com.realtime.crossfire.jxclient.settings.Settings.getLong ( @NotNull final SettingsEntry< Long >  key)

Returns the long associated with the specified key at a node or.

defaultValue

if there is no association for this key.

Parameters
keythe key to get the value for
Returns
the value

Definition at line 115 of file Settings.java.

References com.realtime.crossfire.jxclient.settings.Settings.getString(), and com.realtime.crossfire.jxclient.util.NumberParser.parseLong().

Referenced by com.realtime.crossfire.jxclient.window.JXCConnection.setCharacter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getString()

String com.realtime.crossfire.jxclient.settings.Settings.getString ( @NotNull final SettingsEntry<?>  key)

Returns the string associated with the specified key at a node, or.

defaultValue

if there is no association for this key.

Parameters
keythe key to get the value for
Returns
the value

Definition at line 79 of file Settings.java.

References com.realtime.crossfire.jxclient.settings.Entry.getValue().

Referenced by com.realtime.crossfire.jxclient.window.GuiManager.activateMetaserverGui(), com.realtime.crossfire.jxclient.settings.Settings.getBoolean(), com.realtime.crossfire.jxclient.settings.Settings.getInt(), com.realtime.crossfire.jxclient.settings.Settings.getLong(), com.realtime.crossfire.jxclient.window.GuiManager.openDialog(), and com.realtime.crossfire.jxclient.window.GuiManager.openQueryDialog().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadValues() [1/2]

void com.realtime.crossfire.jxclient.settings.Settings.loadValues ( )
private

Loads the values from the backing file.

Definition at line 193 of file Settings.java.

Referenced by com.realtime.crossfire.jxclient.settings.Settings.Settings().

+ Here is the caller graph for this function:

◆ loadValues() [2/2]

void com.realtime.crossfire.jxclient.settings.Settings.loadValues ( @NotNull final LineNumberReader  lnr) throws IOException
private

Loads the values.

Parameters
lnrthe line number reader from
Exceptions
IOExceptionif an I/O error occurs

Definition at line 216 of file Settings.java.

References com.realtime.crossfire.jxclient.util.Codec.decode(), and com.realtime.crossfire.jxclient.settings.Settings.putString().

+ Here is the call graph for this function:

◆ putBoolean()

void com.realtime.crossfire.jxclient.settings.Settings.putBoolean ( @NotNull final SettingsEntry< Boolean >  key,
final boolean  value 
)

Stores a key/value pair.

Parameters
keythe key to store
valuethe value to store

Definition at line 142 of file Settings.java.

References com.realtime.crossfire.jxclient.settings.Settings.putString().

Referenced by com.realtime.crossfire.jxclient.settings.options.OptionManager.saveOptions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ putInt()

void com.realtime.crossfire.jxclient.settings.Settings.putInt ( @NotNull final SettingsEntry< Integer >  key,
final int  value 
)

Stores a key/value pair.

Parameters
keythe key to store
valuethe value to store

Definition at line 151 of file Settings.java.

References com.realtime.crossfire.jxclient.settings.Settings.putString().

+ Here is the call graph for this function:

◆ putLong()

void com.realtime.crossfire.jxclient.settings.Settings.putLong ( @NotNull final SettingsEntry< Long >  key,
final long  value 
)

Stores a key/value pair.

Parameters
keythe key to store
valuethe value to store

Definition at line 160 of file Settings.java.

References com.realtime.crossfire.jxclient.settings.Settings.putString().

Referenced by com.realtime.crossfire.jxclient.window.JXCConnection.setCharacter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ putString()

◆ remove()

void com.realtime.crossfire.jxclient.settings.Settings.remove ( @NotNull final String  key)

Removes a key.

Does nothing if the key has no associated value.

Parameters
keythe key to remove

Definition at line 168 of file Settings.java.

References com.realtime.crossfire.jxclient.settings.Settings.setChanged().

Referenced by com.realtime.crossfire.jxclient.main.JXClient.JXClient(), and com.realtime.crossfire.jxclient.window.JXCConnection.setCharacter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveNode()

static void com.realtime.crossfire.jxclient.settings.Settings.saveNode ( @NotNull final BufferedWriter  writer,
@NotNull final Map< String, Entry node 
) throws IOException
staticprivate

Saves one node.

Parameters
writerthe
Writer
to write to
nodethe node to save
Exceptions
IOExceptionif the node cannot be saved

Definition at line 264 of file Settings.java.

References com.realtime.crossfire.jxclient.util.Codec.encode(), com.realtime.crossfire.jxclient.settings.Entry.getDocumentation(), and com.realtime.crossfire.jxclient.settings.Entry.getValue().

Referenced by com.realtime.crossfire.jxclient.settings.Settings.saveValues().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveValues()

void com.realtime.crossfire.jxclient.settings.Settings.saveValues ( ) throws IOException
private

Saves the values to the backing file.

Exceptions
IOExceptionif the values cannot be saved

Definition at line 243 of file Settings.java.

References com.realtime.crossfire.jxclient.settings.Settings.saveNode().

Referenced by com.realtime.crossfire.jxclient.settings.Settings.setChanged().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setChanged()

void com.realtime.crossfire.jxclient.settings.Settings.setChanged ( )
private

This function is called whenever the contents of values has changed.

Definition at line 178 of file Settings.java.

References com.realtime.crossfire.jxclient.settings.Settings.saveValues().

Referenced by com.realtime.crossfire.jxclient.settings.Settings.putString(), and com.realtime.crossfire.jxclient.settings.Settings.remove().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ file

final File com.realtime.crossfire.jxclient.settings.Settings.file
private

The file for loading/saving values.

Definition at line 49 of file Settings.java.

Referenced by com.realtime.crossfire.jxclient.settings.Settings.Settings().

◆ noSave

boolean com.realtime.crossfire.jxclient.settings.Settings.noSave = true
private

Flag to inhibit saving.

Definition at line 60 of file Settings.java.

◆ values

final Map<String, Entry> com.realtime.crossfire.jxclient.settings.Settings.values = new TreeMap<>()
private

The stored values.

Maps key name to value.

Definition at line 55 of file Settings.java.


The documentation for this class was generated from the following file: