com.realtime.crossfire.jxclient.settings.options
Class OptionManager

java.lang.Object
  extended by com.realtime.crossfire.jxclient.settings.options.OptionManager

public class OptionManager
extends java.lang.Object

Maintains a set of named options.


Field Summary
private  java.util.Map<java.lang.String,Option> options
          Maps option name to option instance.
private  Settings settings
          The settings instance for loading/saving option values.
 
Constructor Summary
OptionManager(Settings settings)
          Create a new instance.
 
Method Summary
 void addOption(java.lang.String optionName, java.lang.String documentation, Option option)
          Add a new option.
 CheckBoxOption getCheckBoxOption(java.lang.String optionName)
          Return a check box option.
 void loadOptions()
          Load all options' states from the backing settings instance.
 void removeOption(java.lang.String optionName)
          Removes an option by name.
 void saveOptions()
          Save all options' states to the backing settings instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

options

@NotNull
private final java.util.Map<java.lang.String,Option> options
Maps option name to option instance.


settings

@NotNull
private final Settings settings
The settings instance for loading/saving option values.

Constructor Detail

OptionManager

public OptionManager(@NotNull
                     Settings settings)
Create a new instance.

Parameters:
settings - The settings instance for loading/saving option values.
Method Detail

addOption

public void addOption(@NotNull
                      java.lang.String optionName,
                      @NotNull
                      java.lang.String documentation,
                      @NotNull
                      Option option)
               throws OptionException
Add a new option.

Parameters:
optionName - The option name to add.
documentation - The documentation string for the settings.
option - The option to add.
Throws:
OptionException - If the option name is not unique.

getCheckBoxOption

@NotNull
public CheckBoxOption getCheckBoxOption(@NotNull
                                                java.lang.String optionName)
                                 throws OptionException
Return a check box option.

Parameters:
optionName - The option name to look up.
Returns:
The option.
Throws:
OptionException - If the option name does not exist.

loadOptions

public void loadOptions()
Load all options' states from the backing settings instance.


removeOption

public void removeOption(@NotNull
                         java.lang.String optionName)
Removes an option by name. Does nothing if the option does not exist.

Parameters:
optionName - the option name to remove

saveOptions

public void saveOptions()
Save all options' states to the backing settings instance.