LimeWire Consolidated API

org.limewire.setting
Class AbstractNumberSetting<T extends Number & Comparable<T>>

java.lang.Object
  extended by org.limewire.setting.AbstractSetting
      extended by org.limewire.setting.AbstractNumberSetting<T>
All Implemented Interfaces:
Setting
Direct Known Subclasses:
ByteSetting, FloatSetting, IntSetting, LongSetting

public abstract class AbstractNumberSetting<T extends Number & Comparable<T>>
extends AbstractSetting

Provides a Number setting value and ensures any value you set in the future falls within a range. As a subclass of Setting, the setting has a key. If the value is set outside the number range, the value is set to the closer value of either the minimum or maximum range value. For example, if the range is [0,2] and you set the value to 8, the value is actually set to 2.

Additionally, AbstractNumber defines a method for subclasses to convert a string to a Comparable.


Field Summary
protected  T MAX_VALUE
          Adds a safeguard against remote making a setting take a value beyond the reasonable max
protected  T MIN_VALUE
          Adds a safeguard against remote making a setting take a value below the reasonable min
 
Fields inherited from class org.limewire.setting.AbstractSetting
DEFAULT_PROPS, DEFAULT_VALUE, KEY, PROPS
 
Constructor Summary
protected AbstractNumberSetting(Properties defaultProps, Properties props, String key, String defaultValue, boolean remote, T min, T max)
           
 
Method Summary
protected abstract  Comparable<T> convertToComparable(String value)
          Converts a String to a Comparable of the same type as MAX_VALUE and MIN_VALUE.
protected  String normalizeValue(String value)
          Normalizes a value to an acceptable value for this setting.
protected  void setValueInternal(String value)
          Set new property value
 
Methods inherited from class org.limewire.setting.AbstractSetting
addSettingListener, fireSettingEvent, fireSettingEvent, getKey, getSettingListeners, getValueAsString, isDefault, isPrivate, loadValue, reload, removeSettingListener, revertToDefault, setAlwaysSave, setPrivate, shouldAlwaysSave, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_VALUE

protected final T extends Number & Comparable<T> MAX_VALUE
Adds a safeguard against remote making a setting take a value beyond the reasonable max


MIN_VALUE

protected final T extends Number & Comparable<T> MIN_VALUE
Adds a safeguard against remote making a setting take a value below the reasonable min

Constructor Detail

AbstractNumberSetting

protected AbstractNumberSetting(Properties defaultProps,
                                Properties props,
                                String key,
                                String defaultValue,
                                boolean remote,
                                T min,
                                T max)
Method Detail

setValueInternal

protected void setValueInternal(String value)
Set new property value

Overrides:
setValueInternal in class AbstractSetting
Parameters:
value - new property value

normalizeValue

protected String normalizeValue(String value)
Normalizes a value to an acceptable value for this setting.


convertToComparable

protected abstract Comparable<T> convertToComparable(String value)
Converts a String to a Comparable of the same type as MAX_VALUE and MIN_VALUE.


LimeWire Consolidated API

Copyright © 2009. All Rights Reserved.