Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.cwru.SimpleRTS.util
Class Configuration

    java.lang.Object
      edu.cwru.SimpleRTS.util.Configuration

    public final class Configuration

extends java.lang.Object

Manages a list of preferences and allows for saving to/loading from a file.

Author:
  Tim

Method Summary
`java.lang.String` | `get(java.lang.String key)` Returns the value of the preference indicated by the given key, or null if no such preference is registered.
`static Configuration` | `getInstance()`
`java.util.Set<java.lang.String>` | `keySet()` Returns a read-only view of the names of all registered preferences.
`boolean` | `load(java.lang.String filename)` Attempts to load a set of preferences from a file.
`java.lang.String` | `put(java.lang.String key, java.lang.String value)` Registers or overwrites a preference.
`boolean` | `save()` Stores the current set of preferences to the file set by `load(String)` or `saveAs(String)`.
`boolean` | `saveAs(java.lang.String filename)` Sets the name of the file to which the preferences should be saved and then saves.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### getInstance

    public static Configuration getInstance()

### load

    public boolean load(java.lang.String filename)

  Attempts to load a set of preferences from a file.

  Parameters:
    `filename` - - the name of the file from which to load preferences
  Returns:
    whether an error occurred when opening the file

### save

    public boolean save()

  Stores the current set of preferences to the file set by `load(String)` or `saveAs(String)`.

  Returns:
    whether or not an error occurred when opening the file

### saveAs

    public boolean saveAs(java.lang.String filename)

  Sets the name of the file to which the preferences should be saved and then saves.

  Parameters:
    `filename` - - the name of the file to which to save preferences
  Returns:
    whether there was an error when opening the file

### get

    public java.lang.String get(java.lang.String key)

  Returns the value of the preference indicated by the given key, or null if no such preference is registered.

  Parameters:
    `key` - - the name of the preference
  Returns:
    the value of the preference or null

### put

    public java.lang.String put(java.lang.String key,
                                java.lang.String value)

  Registers or overwrites a preference.

  Parameters:
    `key` - - the name of the preference
    `value` - - the value of the preference
  Returns:
    the previous value of the preference if it was overwritten, or null otherwise

### keySet

    public java.util.Set<java.lang.String> keySet()

  Returns a read-only view of the names of all registered preferences.

  Returns:

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD