Crossfire JXClient, Trunk
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
com.realtime.crossfire.jxclient.settings.Settings Class Reference
Collaboration diagram for com.realtime.crossfire.jxclient.settings.Settings:
Collaboration graph

Public Member Functions

boolean getBoolean (@NotNull final SettingsEntry< Boolean > key)
 
int getInt (@NotNull final SettingsEntry< Integer > key)
 
long getLong (@NotNull final SettingsEntry< Long > key)
 
String getString (@NotNull final SettingsEntry<?> key)
 
void putBoolean (@NotNull final SettingsEntry< Boolean > key, final boolean value)
 
void putInt (@NotNull final SettingsEntry< Integer > key, final int value)
 
void putLong (@NotNull final SettingsEntry< Long > key, final long value)
 
void putString (@NotNull final SettingsEntry<?> key, @NotNull final String value)
 
void remove (@NotNull final String key)
 
 Settings (@NotNull final Path file)
 

Private Member Functions

void loadValues ()
 
void loadValues (@NotNull final LineNumberReader lnr) throws IOException
 
void saveValues () throws IOException
 
void setChanged ()
 

Static Private Member Functions

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

Private Attributes

final Path file
 
boolean noSave = true
 
final Map< String, Entryvalues = new TreeMap<>()
 

Detailed Description

Maintains a set of key/value pairs. The values are stored in a flat file.

Author
Andreas Kirschbaum

Definition at line 45 of file Settings.java.

Constructor & Destructor Documentation

◆ Settings()

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

Creates a new instance.

Parameters
filethe file for loading/saving values

Definition at line 68 of file Settings.java.

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

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 95 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 110 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 120 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 81 of file Settings.java.

References com.realtime.crossfire.jxclient.settings.Entry.getValue(), and com.realtime.crossfire.jxclient.settings.Settings.values.

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 202 of file Settings.java.

References com.realtime.crossfire.jxclient.settings.Settings.file, and com.realtime.crossfire.jxclient.settings.Settings.values.

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 223 of file Settings.java.

References com.realtime.crossfire.jxclient.util.Codec.decode(), com.realtime.crossfire.jxclient.settings.Settings.file, 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 151 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 160 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 169 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()

void com.realtime.crossfire.jxclient.settings.Settings.putString ( @NotNull final SettingsEntry<?>  key,
@NotNull final String  value 
)

◆ 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 177 of file Settings.java.

References com.realtime.crossfire.jxclient.settings.Settings.setChanged(), and com.realtime.crossfire.jxclient.settings.Settings.values.

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 272 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 257 of file Settings.java.

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

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 187 of file Settings.java.

References com.realtime.crossfire.jxclient.settings.Settings.file, com.realtime.crossfire.jxclient.settings.Settings.noSave, and 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 Path com.realtime.crossfire.jxclient.settings.Settings.file
private

◆ noSave

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

◆ values

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

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