megamek.common.preference
Class PreferenceStore

java.lang.Object
  extended by megamek.common.preference.PreferenceStore
All Implemented Interfaces:
IPreferenceStore

 class PreferenceStore
extends java.lang.Object
implements IPreferenceStore


Field Summary
protected  java.util.Properties defaultProperties
           
protected  boolean dirty
           
protected  java.util.Vector<IPreferenceChangeListener> listeners
           
protected  java.util.Properties properties
           
 
Fields inherited from interface megamek.common.preference.IPreferenceStore
BOOLEAN_DEFAULT, DOUBLE_DEFAULT, FALSE, FLOAT_DEFAULT, INT_DEFAULT, LONG_DEFAULT, STRING_DEFAULT, TRUE
 
Constructor Summary
PreferenceStore()
           
 
Method Summary
 void addPreferenceChangeListener(IPreferenceChangeListener listener)
          Adds a preference change listener to this store.
protected  void firePropertyChangeEvent(java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)
           
 java.lang.String[] getAdvancedProperties()
           
 boolean getBoolean(java.lang.String name)
          Returns the value of the boolean preference with the given name.
 boolean getDefaultBoolean(java.lang.String name)
          Returns the default value for the boolean preference with the given name.
 double getDefaultDouble(java.lang.String name)
          Returns the default value for the double preference with the given name.
 float getDefaultFloat(java.lang.String name)
          Returns the default value for the float preference with the given name.
 int getDefaultInt(java.lang.String name)
          Returns the default value for the int preference with the given name.
 long getDefaultLong(java.lang.String name)
          Returns the default value for the long preference with the given name.
 java.lang.String getDefaultString(java.lang.String name)
          Returns the default value for the String preference with the given name.
 double getDouble(java.lang.String name)
          Returns the value of the double preference with the given name.
 float getFloat(java.lang.String name)
          Returns the value of the float preference with the given name.
 int getInt(java.lang.String name)
          Returns the value of the int preference with the given name.
 long getLong(java.lang.String name)
          Returns the value of the long preference with the given name.
 java.lang.String getString(java.lang.String name)
          Returns the value of the String preference with the given name.
protected  void put(java.util.Properties p, java.lang.String name, java.lang.String value)
           
 void putValue(java.lang.String name, java.lang.String value)
          Just sets the current value of the preference with the given name.
 void removePreferenceChangeListener(IPreferenceChangeListener listener)
          Removes the given listener from this store.
 void setDefault(java.lang.String name, boolean value)
          Sets the default value for the boolean preference with the given name.
 void setDefault(java.lang.String name, double value)
          Sets the default value for the double preference with the given name.
 void setDefault(java.lang.String name, float value)
          Sets the default value for the float preference with the given name.
 void setDefault(java.lang.String name, int value)
          Sets the default value for the int preference with the given name.
 void setDefault(java.lang.String name, long value)
          Sets the default value for the long preference with the given name.
 void setDefault(java.lang.String name, java.lang.String value)
          Sets the default value for the string preference with the given name.
 void setValue(java.lang.String name, boolean value)
          Sets the current value of the boolean preference with the given name.
 void setValue(java.lang.String name, double value)
          Sets the current value of the double preference with the given name.
 void setValue(java.lang.String name, float value)
          Sets the current value of the float preference with the given name.
 void setValue(java.lang.String name, int value)
          Sets the current value of the int preference with the given name.
 void setValue(java.lang.String name, long value)
          Sets the current value of the long preference with the given name.
 void setValue(java.lang.String name, java.lang.String value)
          Sets the current value of the String preference with the given name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dirty

protected boolean dirty

properties

protected java.util.Properties properties

defaultProperties

protected java.util.Properties defaultProperties

listeners

protected java.util.Vector<IPreferenceChangeListener> listeners
Constructor Detail

PreferenceStore

public PreferenceStore()
Method Detail

getDefaultBoolean

public boolean getDefaultBoolean(java.lang.String name)
Description copied from interface: IPreferenceStore
Returns the default value for the boolean preference with the given name.

Specified by:
getDefaultBoolean in interface IPreferenceStore

getDefaultInt

public int getDefaultInt(java.lang.String name)
Description copied from interface: IPreferenceStore
Returns the default value for the int preference with the given name.

Specified by:
getDefaultInt in interface IPreferenceStore

getDefaultLong

public long getDefaultLong(java.lang.String name)
Description copied from interface: IPreferenceStore
Returns the default value for the long preference with the given name.

Specified by:
getDefaultLong in interface IPreferenceStore

getDefaultString

public java.lang.String getDefaultString(java.lang.String name)
Description copied from interface: IPreferenceStore
Returns the default value for the String preference with the given name.

Specified by:
getDefaultString in interface IPreferenceStore

getDefaultDouble

public double getDefaultDouble(java.lang.String name)
Description copied from interface: IPreferenceStore
Returns the default value for the double preference with the given name.

Specified by:
getDefaultDouble in interface IPreferenceStore

getDefaultFloat

public float getDefaultFloat(java.lang.String name)
Description copied from interface: IPreferenceStore
Returns the default value for the float preference with the given name.

Specified by:
getDefaultFloat in interface IPreferenceStore

getBoolean

public boolean getBoolean(java.lang.String name)
Description copied from interface: IPreferenceStore
Returns the value of the boolean preference with the given name. Returns the predefined default value in case if there is no preference with the given name, or if the current value cannot be treated as a boolean.

Specified by:
getBoolean in interface IPreferenceStore

getDouble

public double getDouble(java.lang.String name)
Description copied from interface: IPreferenceStore
Returns the value of the double preference with the given name. Returns the predefined default value in case if there is no preference with the given name, or if the current value cannot be treated as a double.

Specified by:
getDouble in interface IPreferenceStore

getFloat

public float getFloat(java.lang.String name)
Description copied from interface: IPreferenceStore
Returns the value of the float preference with the given name. Returns the predefined default value in case if there is no preference with the given name, or if the current value cannot be treated as a float.

Specified by:
getFloat in interface IPreferenceStore

getInt

public int getInt(java.lang.String name)
Description copied from interface: IPreferenceStore
Returns the value of the int preference with the given name. Returns the predefined default value in case if there is no preference with the given name, or if the current value cannot be treated as a int.

Specified by:
getInt in interface IPreferenceStore

getLong

public long getLong(java.lang.String name)
Description copied from interface: IPreferenceStore
Returns the value of the long preference with the given name. Returns the predefined default value in case if there is no preference with the given name, or if the current value cannot be treated as a long.

Specified by:
getLong in interface IPreferenceStore

getString

public java.lang.String getString(java.lang.String name)
Description copied from interface: IPreferenceStore
Returns the value of the String preference with the given name. Returns the predefined default value in case if there is no preference with the given name, or if the current value cannot be treated as a String.

Specified by:
getString in interface IPreferenceStore

setDefault

public void setDefault(java.lang.String name,
                       double value)
Description copied from interface: IPreferenceStore
Sets the default value for the double preference with the given name.

Specified by:
setDefault in interface IPreferenceStore

setDefault

public void setDefault(java.lang.String name,
                       float value)
Description copied from interface: IPreferenceStore
Sets the default value for the float preference with the given name.

Specified by:
setDefault in interface IPreferenceStore

setDefault

public void setDefault(java.lang.String name,
                       int value)
Description copied from interface: IPreferenceStore
Sets the default value for the int preference with the given name.

Specified by:
setDefault in interface IPreferenceStore

setDefault

public void setDefault(java.lang.String name,
                       long value)
Description copied from interface: IPreferenceStore
Sets the default value for the long preference with the given name.

Specified by:
setDefault in interface IPreferenceStore

setDefault

public void setDefault(java.lang.String name,
                       java.lang.String value)
Description copied from interface: IPreferenceStore
Sets the default value for the string preference with the given name.

Specified by:
setDefault in interface IPreferenceStore

setDefault

public void setDefault(java.lang.String name,
                       boolean value)
Description copied from interface: IPreferenceStore
Sets the default value for the boolean preference with the given name.

Specified by:
setDefault in interface IPreferenceStore

setValue

public void setValue(java.lang.String name,
                     double value)
Description copied from interface: IPreferenceStore
Sets the current value of the double preference with the given name. A preference change event is reported if the current value of the preference changes from its previous value.

Specified by:
setValue in interface IPreferenceStore

setValue

public void setValue(java.lang.String name,
                     float value)
Description copied from interface: IPreferenceStore
Sets the current value of the float preference with the given name. A preference change event is reported if the current value of the preference changes from its previous value.

Specified by:
setValue in interface IPreferenceStore

setValue

public void setValue(java.lang.String name,
                     int value)
Description copied from interface: IPreferenceStore
Sets the current value of the int preference with the given name. A preference change event is reported if the current value of the preference changes from its previous value.

Specified by:
setValue in interface IPreferenceStore

setValue

public void setValue(java.lang.String name,
                     long value)
Description copied from interface: IPreferenceStore
Sets the current value of the long preference with the given name. A preference change event is reported if the current value of the preference changes from its previous value.

Specified by:
setValue in interface IPreferenceStore

setValue

public void setValue(java.lang.String name,
                     java.lang.String value)
Description copied from interface: IPreferenceStore
Sets the current value of the String preference with the given name. A preference change event is reported if the current value of the preference changes from its previous value.

Specified by:
setValue in interface IPreferenceStore

setValue

public void setValue(java.lang.String name,
                     boolean value)
Description copied from interface: IPreferenceStore
Sets the current value of the boolean preference with the given name. A preference change event is reported if the current value of the preference changes from its previous value.

Specified by:
setValue in interface IPreferenceStore

putValue

public void putValue(java.lang.String name,
                     java.lang.String value)
Description copied from interface: IPreferenceStore
Just sets the current value of the preference with the given name. does not fire preference change event

Specified by:
putValue in interface IPreferenceStore

put

protected void put(java.util.Properties p,
                   java.lang.String name,
                   java.lang.String value)

addPreferenceChangeListener

public void addPreferenceChangeListener(IPreferenceChangeListener listener)
Description copied from interface: IPreferenceStore
Adds a preference change listener to this store.

Specified by:
addPreferenceChangeListener in interface IPreferenceStore
Parameters:
listener - a preference change listener

removePreferenceChangeListener

public void removePreferenceChangeListener(IPreferenceChangeListener listener)
Description copied from interface: IPreferenceStore
Removes the given listener from this store.

Specified by:
removePreferenceChangeListener in interface IPreferenceStore

firePropertyChangeEvent

protected void firePropertyChangeEvent(java.lang.String name,
                                       java.lang.Object oldValue,
                                       java.lang.Object newValue)

getAdvancedProperties

public java.lang.String[] getAdvancedProperties()
Specified by:
getAdvancedProperties in interface IPreferenceStore