org.xnap.commons.settings
Class AbstractSetting<T>

java.lang.Object
  extended by org.xnap.commons.settings.AbstractSetting<T>
All Implemented Interfaces:
Setting<T>
Direct Known Subclasses:
BooleanSetting, ClassNameSetting, ColorSetting, EnumSetting, FontSetting, IntArraySetting, IntSetting, KeyStrokeSetting, SerializableSetting, StringArraySetting, StringSetting

public abstract class AbstractSetting<T>
extends Object
implements Setting<T>

Provides a default implementation of a setting.


Field Summary
static String ARRAY_SEPARATOR
           
protected  SettingResource backstore
           
 
Constructor Summary
AbstractSetting(SettingResource backstore, String key, T defaultValue, Validator validator)
           
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener l)
          Adds a preferences listener.
static boolean areObjectsEqual(Object[] obj1, Object[] obj2)
          Determine if 2 arrays are equal, or both point to null.
static boolean areObjectsEqual(Object obj1, Object obj2)
          Determine if 2 objects are equal, or both point to null.
protected abstract  T fromString(String s)
          Sets the value of the setting from s.
 T getDefaultValue()
           
 String getKey()
          Returns the unique key used that used to identify the setting.
 SettingResource getProperties()
           
 Validator getValidator()
           
 T getValue()
           
 void removePropertyChangeListener(PropertyChangeListener l)
           
 void revert()
          Reverts the setting to its default value.
protected  void setDefaultValue(T defaultValue)
           
 void setProperties(PropertyResource properties)
           
 void setValidator(Validator validator)
           
 void setValue(T newValue)
           
protected abstract  String toString(T object)
          Returns a string representation of the setting.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ARRAY_SEPARATOR

public static final String ARRAY_SEPARATOR
See Also:
Constant Field Values

backstore

protected SettingResource backstore
Constructor Detail

AbstractSetting

public AbstractSetting(SettingResource backstore,
                       String key,
                       T defaultValue,
                       Validator validator)
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)
Adds a preferences listener.


areObjectsEqual

public static boolean areObjectsEqual(Object obj1,
                                      Object obj2)
Determine if 2 objects are equal, or both point to null.


areObjectsEqual

public static boolean areObjectsEqual(Object[] obj1,
                                      Object[] obj2)
Determine if 2 arrays are equal, or both point to null.


fromString

protected abstract T fromString(String s)
Sets the value of the setting from s.


getKey

public String getKey()
Description copied from interface: Setting
Returns the unique key used that used to identify the setting.

Specified by:
getKey in interface Setting<T>

getDefaultValue

public T getDefaultValue()
Specified by:
getDefaultValue in interface Setting<T>

getProperties

public SettingResource getProperties()

getValue

public T getValue()
Specified by:
getValue in interface Setting<T>

getValidator

public Validator getValidator()

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)

revert

public void revert()
Description copied from interface: Setting
Reverts the setting to its default value.

Specified by:
revert in interface Setting<T>

setDefaultValue

protected void setDefaultValue(T defaultValue)

setProperties

public void setProperties(PropertyResource properties)

setValue

public void setValue(T newValue)
Specified by:
setValue in interface Setting<T>

setValidator

public void setValidator(Validator validator)

toString

protected abstract String toString(T object)
Returns a string representation of the setting. The string is written to the settings file.

See Also:
fromString(String)


Copyright © 2004-2007 XNap Commons Team. All Rights Reserved.