summaryrefslogtreecommitdiff
path: root/sources/prefs/VSPrefs.java
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-05-26 15:59:39 +0000
committerPaul Buetow <paul@buetow.org>2008-05-26 15:59:39 +0000
commitd0b6e434d76cfea9e3096f0d50706c9a286a4b9d (patch)
treeeeb76b267bdfb08e328794679e713065dd6755b5 /sources/prefs/VSPrefs.java
parent9ffbf6d8b94e8ae40ebc291eab6bd96aff3477b0 (diff)
VSPrefs sorted.
Diffstat (limited to 'sources/prefs/VSPrefs.java')
-rw-r--r--sources/prefs/VSPrefs.java681
1 files changed, 326 insertions, 355 deletions
diff --git a/sources/prefs/VSPrefs.java b/sources/prefs/VSPrefs.java
index 5d23ad0..dd274b9 100644
--- a/sources/prefs/VSPrefs.java
+++ b/sources/prefs/VSPrefs.java
@@ -44,7 +44,7 @@ public abstract class VSPrefs implements Serializable {
private HashMap<String,Long> longPrefs;
/** The setting restriction prefs. */
- private HashMap<String,SettingRestriction> settingRestrictionPrefs;
+ private HashMap<String,VSPrefRestriction> restrictions;
/** The description prefs. */
private HashMap<String,String> descriptionPrefs;
@@ -74,16 +74,16 @@ public abstract class VSPrefs implements Serializable {
protected long id;
/**
- * The Class SettingRestriction.
+ * The Class VSPrefRestriction.
*/
- public class SettingRestriction implements Serializable {
+ public class VSPrefRestriction implements Serializable {
private static final long serialVersionUID = 1L;
}
/**
- * The Class IntegerSettingRestriction.
+ * The Class VSIntegerPrefRestriction.
*/
- public class IntegerSettingRestriction extends SettingRestriction {
+ public class VSIntegerPrefRestriction extends VSPrefRestriction {
private static final long serialVersionUID = 1L;
/** The min value. */
private int minValue;
@@ -97,7 +97,7 @@ public abstract class VSPrefs implements Serializable {
* @param minValue the min value
* @param maxValue the max value
*/
- public IntegerSettingRestriction(int minValue, int maxValue) {
+ public VSIntegerPrefRestriction(int minValue, int maxValue) {
this.minValue = minValue;
this.maxValue = maxValue;
}
@@ -122,9 +122,9 @@ public abstract class VSPrefs implements Serializable {
}
/**
- * The Class StringSettingRestriction.
+ * The Class StringVSPrefRestriction.
*/
- public class StringSettingRestriction extends SettingRestriction {
+ public class StringVSPrefRestriction extends VSPrefRestriction {
private static final long serialVersionUID = 1L;
/** The possible selections. */
@@ -135,7 +135,7 @@ public abstract class VSPrefs implements Serializable {
*
* @param possibleSelections the possible selections
*/
- public StringSettingRestriction(String [] possibleSelections) {
+ public StringVSPrefRestriction(String [] possibleSelections) {
this.possibleSelections = new Vector<String>();
for (String elem : possibleSelections)
@@ -161,7 +161,7 @@ public abstract class VSPrefs implements Serializable {
floatPrefs = new HashMap<String,Float>();
integerPrefs = new HashMap<String,Integer>();
longPrefs = new HashMap<String,Long>();
- settingRestrictionPrefs = new HashMap<String,SettingRestriction>();
+ restrictions = new HashMap<String,VSPrefRestriction>();
stringPrefs = new HashMap<String,String>();
booleanPrefs = new HashMap<String,Boolean>();
objectPrefs = new HashMap<String,Object>();
@@ -181,139 +181,106 @@ public abstract class VSPrefs implements Serializable {
booleanPrefs.clear();
objectPrefs.clear();
descriptionPrefs.clear();
- settingRestrictionPrefs.clear();
+ restrictions.clear();
}
+ /* Unit methods */
+
/**
- * Gets the object.
+ * Gets the unit.
*
* @param key the key
*
- * @return the object
+ * @return the unit
*/
- public synchronized Object getObject(String key) {
- Object val = objectPrefs.get(key);
-
- if (val == null) {
- System.err.println("Fatal: No such object config value \""
- + key + "\"");
- System.exit(1);
- }
-
- return val;
+ public synchronized String getUnit(String fullKey) {
+ return units.get(fullKey);
}
/**
- * Removes the object.
+ * Sets the unit.
*
* @param key the key
+ * @param unit the unit
*/
- public synchronized void removeObject(String key) {
- objectPrefs.remove(key);
+ public synchronized void initUnit(String key, String unit) {
+ if (unit == null || units.containsKey(key))
+ return;
+ units.put(key, unit);
}
+ /* Description methods */
/**
- * Object exists.
+ * Sets the description if unset.
*
* @param key the key
- *
- * @return true, if successful
+ * @param descr the descr
*/
- public synchronized boolean objectExists(String key) {
- return null != objectPrefs.get(key);
+ public synchronized void initDescription(String key, String descr) {
+ if (descr == null || descriptionPrefs.containsKey(key))
+ return;
+ descriptionPrefs.put(key, descr);
}
/**
- * Gets the string.
+ * Gets the description.
*
* @param key the key
*
- * @return the string
+ * @return the description
*/
- public synchronized String getString(String key) {
- String val = stringPrefs.get(key);
-
- if (val == null) {
- System.err.println("Fatal: No such string config value \""
- + key + "\"");
- System.exit(1);
- }
-
- return val;
+ public synchronized String getDescription(String fullKey) {
+ return descriptionPrefs.get(fullKey);
}
- /**
- * Gets the integer obj.
- *
- * @param key the key
- *
- * @return the integer obj
- */
- public synchronized Integer getIntegerObj(String key) {
- Integer val = integerPrefs.get(key);
-
- if (val == null) {
- System.err.println("Fatal: No such integer config value \""
- + key + "\"");
- System.exit(1);
- }
-
- return val;
- }
+ /* Restriction methods */
/**
- * Gets the integer.
+ * Gets the restriction.
*
* @param key the key
*
- * @return the integer
+ * @return the restriction
*/
- public int getInteger(String key) {
- return getIntegerObj(key).intValue();
+ public synchronized VSPrefRestriction getRestriction(String fullKey) {
+ return restrictions.get(fullKey);
}
/**
- * Gets the float obj.
+ * Sets the restriction.
*
* @param key the key
- *
- * @return the float obj
+ * @param settingRestriction the setting restriction
*/
- public synchronized Float getFloatObj(String key) {
- Float val = floatPrefs.get(key);
-
- if (val == null) {
- System.err.println("Fatal: No such float config value \""
- + key + "\"");
- System.exit(1);
- }
-
- return val;
+ public synchronized void initRestriction(String key, VSPrefRestriction settingRestriction) {
+ restrictions.put(key, settingRestriction);
}
+ /* Object methods */
+
/**
- * Gets the float.
+ * Object exists.
*
* @param key the key
*
- * @return the float
+ * @return true, if successful
*/
- public float getFloat(String key) {
- return getFloatObj(key).floatValue();
+ public synchronized boolean objectExists(String key) {
+ return null != objectPrefs.get(key);
}
/**
- * Gets the long obj.
+ * Gets the object.
*
* @param key the key
*
- * @return the long obj
+ * @return the object
*/
- public synchronized Long getLongObj(String key) {
- Long val = longPrefs.get(key);
+ public synchronized Object getObject(String key) {
+ Object val = objectPrefs.get(key);
if (val == null) {
- System.err.println("Fatal: No such long config value \""
+ System.err.println("Fatal: No such object config value \""
+ key + "\"");
System.exit(1);
}
@@ -322,32 +289,26 @@ public abstract class VSPrefs implements Serializable {
}
/**
- * Gets the long.
+ * Removes the object.
*
* @param key the key
- *
- * @return the long
*/
- public long getLong(String key) {
- return getLongObj(key).longValue();
+ public synchronized void removeObject(String key) {
+ objectPrefs.remove(key);
}
/**
- * Gets the boolean obj.
+ * Sets the object.
*
* @param key the key
- *
- * @return the boolean obj
+ * @param val the val
*/
- public synchronized Boolean getBooleanObj(String key) {
- Boolean val = booleanPrefs.get(key);
-
- if (val == null)
- return new Boolean(false);
-
- return val;
+ public synchronized void setObject(String key, Object val) {
+ objectPrefs.put(key, val);
}
+ /* Boolean methods */
+
/**
* Gets the boolean.
*
@@ -360,100 +321,102 @@ public abstract class VSPrefs implements Serializable {
}
/**
- * Gets the color.
- *
- * @param key the key
+ * Gets the boolean key set.
*
- * @return the color
+ * @return the boolean key set
*/
- public synchronized Color getColor(String key) {
- Color color = colorPrefs.get(key);
-
- if (color == null) {
- System.err.println("Fatal: No such color config value \""
- + key + "\"");
- System.exit(1);
- }
-
- return color;
+ public synchronized Set<String> getBooleanKeySet() {
+ return booleanPrefs.keySet();
}
/**
- * Gets the description.
+ * Gets the boolean obj.
*
* @param key the key
*
- * @return the description
+ * @return the boolean obj
*/
- public synchronized String getDescription(String key) {
- return descriptionPrefs.get(key);
+ public synchronized Boolean getBooleanObj(String key) {
+ Boolean val = booleanPrefs.get(key);
+
+ if (val == null)
+ return new Boolean(false);
+
+ return val;
}
/**
- * Gets the unit.
+ * Inits the boolean.
*
* @param key the key
- *
- * @return the unit
+ * @param val the val
*/
- public synchronized String getUnit(String key) {
- return units.get(key);
+ public synchronized void initBoolean(String key, Boolean val) {
+ if (!booleanPrefs.containsKey(key))
+ booleanPrefs.put(key, val);
}
/**
- * Gets the restriction.
+ * Inits the boolean.
*
* @param key the key
- *
- * @return the restriction
+ * @param val the val
*/
- public synchronized SettingRestriction getRestriction(String key) {
- return settingRestrictionPrefs.get(key);
+ public void initBoolean(String key, boolean val) {
+ initBoolean(key, new Boolean(val));
}
/**
- * Gets the string key set.
+ * Inits the boolean.
*
- * @return the string key set
+ * @param key the key
+ * @param val the val
+ * @param descr the descr
*/
- public synchronized Set<String> getStringKeySet() {
- return stringPrefs.keySet();
+ public void initBoolean(String key, boolean val, String descr) {
+ initBoolean(key, val);
+ initDescription(BOOLEAN_PREFIX + key, descr);
}
/**
- * Gets the integer key set.
+ * Sets the boolean.
*
- * @return the integer key set
+ * @param key the key
+ * @param val the val
*/
- public synchronized Set<String> getIntegerKeySet() {
- return integerPrefs.keySet();
+ public synchronized void setBoolean(String key, Boolean val) {
+ booleanPrefs.put(key, val);
}
/**
- * Gets the float key set.
+ * Sets the boolean.
*
- * @return the float key set
+ * @param key the key
+ * @param val the val
*/
- public synchronized Set<String> getFloatKeySet() {
- return floatPrefs.keySet();
+ public void setBoolean(String key, boolean val) {
+ setBoolean(key, new Boolean(val));
}
- /**
- * Gets the long key set.
- *
- * @return the long key set
- */
- public synchronized Set<String> getLongKeySet() {
- return longPrefs.keySet();
- }
+ /* Color methods */
/**
- * Gets the boolean key set.
+ * Gets the color.
*
- * @return the boolean key set
+ * @param key the key
+ *
+ * @return the color
*/
- public synchronized Set<String> getBooleanKeySet() {
- return booleanPrefs.keySet();
+ public synchronized Color getColor(String key) {
+ Color color = colorPrefs.get(key);
+
+ if (color == null) {
+ System.err.println("Fatal: No such color config value \""
+ + key + "\"");
+ System.exit(1);
+ }
+
+ return color;
}
/**
@@ -466,33 +429,26 @@ public abstract class VSPrefs implements Serializable {
}
/**
- * Sets the object.
- *
- * @param key the key
- * @param val the val
- */
- public synchronized void setObject(String key, Object val) {
- objectPrefs.put(key, val);
- }
-
- /**
- * Sets the string.
+ * Inits the color.
*
* @param key the key
- * @param val the val
+ * @param color the color
*/
- public synchronized void setString(String key, String val) {
- stringPrefs.put(key, val);
+ public synchronized void initColor(String key, Color color) {
+ if (!colorPrefs.containsKey(key))
+ colorPrefs.put(key, color);
}
/**
- * Sets the integer.
+ * Inits the color.
*
* @param key the key
* @param val the val
+ * @param descr the descr
*/
- public synchronized void setInteger(String key, Integer val) {
- integerPrefs.put(key, val);
+ public void initColor(String key, Color val, String descr) {
+ initColor(key, val);
+ initDescription(COLOR_PREFIX + key, descr);
}
/**
@@ -505,406 +461,421 @@ public abstract class VSPrefs implements Serializable {
colorPrefs.put(key, color);
}
- /**
- * Sets the int.
- *
- * @param key the key
- * @param val the val
- */
- public synchronized void setInt(String key, int val) {
- integerPrefs.put(key, new Integer(val));
- }
+ /* Float methods */
/**
- * Sets the float.
+ * Gets the float.
*
* @param key the key
- * @param val the val
+ *
+ * @return the float
*/
- public synchronized void setFloat(String key, float val) {
- floatPrefs.put(key, new Float(val));
+ public float getFloat(String key) {
+ return getFloatObj(key).floatValue();
}
/**
- * Sets the float.
+ * Gets the float key set.
*
- * @param key the key
- * @param val the val
+ * @return the float key set
*/
- public synchronized void setFloat(String key, Float val) {
- floatPrefs.put(key, val);
+ public synchronized Set<String> getFloatKeySet() {
+ return floatPrefs.keySet();
}
/**
- * Sets the long.
+ * Gets the float obj.
*
* @param key the key
- * @param val the val
+ *
+ * @return the float obj
*/
- public synchronized void setLong(String key, long val) {
- longPrefs.put(key, new Long(val));
+ public synchronized Float getFloatObj(String key) {
+ Float val = floatPrefs.get(key);
+
+ if (val == null) {
+ System.err.println("Fatal: No such float config value \""
+ + key + "\"");
+ System.exit(1);
+ }
+
+ return val;
}
/**
- * Sets the long.
+ * Inits the float.
*
* @param key the key
* @param val the val
*/
- public synchronized void setLong(String key, Long val) {
- longPrefs.put(key, val);
+ public synchronized void initFloat(String key, Float val) {
+ if (!floatPrefs.containsKey(key))
+ floatPrefs.put(key, val);
}
/**
- * Sets the boolean.
+ * Inits the float.
*
* @param key the key
* @param val the val
*/
- public synchronized void setBoolean(String key, boolean val) {
- booleanPrefs.put(key, new Boolean(val));
+ public void initFloat(String key, float val) {
+ initFloat(key, new Float(val));
}
/**
- * Sets the boolean.
+ * Inits the float.
*
* @param key the key
* @param val the val
+ * @param descr the descr
+ * @param unit the unit
*/
- public synchronized void setBoolean(String key, Boolean val) {
- booleanPrefs.put(key, val);
+ public void initFloat(String key, float val, String descr) {
+ initFloat(key, val);
+ initDescription(FLOAT_PREFIX + key, descr);
}
/**
- * Inits the string.
+ * Inits the float plus unit.
*
* @param key the key
* @param val the val
+ * @param descr the descr
+ * @param unit the unit
*/
- public synchronized void initString(String key, String val) {
- if (!stringPrefs.containsKey(key))
- stringPrefs.put(key, val);
+ public void initFloat(String key, float val, String descr, String unit) {
+ initFloat(key, val, descr);
+ initUnit(FLOAT_PREFIX + key, unit);
}
/**
- * Inits the integer.
+ * Sets the float.
*
* @param key the key
* @param val the val
*/
- public synchronized void initLong(String key, Integer val) {
- if (!integerPrefs.containsKey(key))
- integerPrefs.put(key, val);
+ public synchronized void setFloat(String key, Float val) {
+ floatPrefs.put(key, val);
}
/**
- * Inits the long.
+ * Sets the float.
*
* @param key the key
* @param val the val
*/
- public synchronized void initLong(String key, Long val) {
- if (!longPrefs.containsKey(key))
- longPrefs.put(key, val);
+ public void setFloat(String key, float val) {
+ setFloat(key, new Float(val));
}
+ /* Integer methods */
+
/**
- * Inits the float.
+ * Gets the integer.
*
* @param key the key
- * @param val the val
+ *
+ * @return the integer
*/
- public synchronized void initFloat(String key, Float val) {
- if (!floatPrefs.containsKey(key))
- floatPrefs.put(key, val);
+ public int getInteger(String key) {
+ return getIntegerObj(key).intValue();
}
/**
- * Inits the float.
+ * Gets the integer key set.
*
- * @param key the key
- * @param val the val
+ * @return the integer key set
*/
- public void initFloat(String key, float val) {
- initFloat(key, new Float(val));
+ public synchronized Set<String> getIntegerKeySet() {
+ return integerPrefs.keySet();
}
/**
- * Sets the long if unset.
+ * Gets the integer obj.
*
* @param key the key
- * @param val the val
+ *
+ * @return the integer obj
*/
- public void initLong(String key, long val) {
- initLong(key, new Long(val));
+ public synchronized Integer getIntegerObj(String key) {
+ Integer val = integerPrefs.get(key);
+
+ if (val == null) {
+ System.err.println("Fatal: No such integer config value \""
+ + key + "\"");
+ System.exit(1);
+ }
+
+ return val;
}
/**
- * Inits the boolean.
+ * Inits the integer.
*
* @param key the key
* @param val the val
*/
- public synchronized void initBoolean(String key, Boolean val) {
- if (!booleanPrefs.containsKey(key))
- booleanPrefs.put(key, val);
+ public void initInteger(String key, int val) {
+ if (!integerPrefs.containsKey(key))
+ setInteger(key, new Integer(val));
}
/**
- * Inits the boolean.
+ * Inits the integer.
*
* @param key the key
* @param val the val
+ * @param descr the descr
*/
- public void initBoolean(String key, boolean val) {
- initBoolean(key, new Boolean(val));
+ public void initInteger(String key, int val, String descr) {
+ initInteger(key, val);
+ initDescription(INTEGER_PREFIX + key, descr);
}
/**
- * Inits the color.
+ * Inits the integer.
*
* @param key the key
- * @param color the color
+ * @param val the val
+ * @param descr the descr
+ * @param r the restriction
*/
- public synchronized void initColor(String key, Color color) {
- if (!colorPrefs.containsKey(key))
- colorPrefs.put(key, color);
+ public void initInteger(String key, int val, String descr, VSIntegerPrefRestriction r) {
+ initInteger(key, val, descr);
+ initRestriction(INTEGER_PREFIX + key, r);
}
/**
- * Sets the description if unset.
+ * Inits the integer.
*
* @param key the key
+ * @param val the val
* @param descr the descr
+ * @param r the restriction
*/
- public synchronized void initDescription(String key, String descr) {
- if (descr == null || descriptionPrefs.containsKey(key))
- return;
- descriptionPrefs.put(key, descr);
+ public void initInteger(String key, int val, String descr, VSIntegerPrefRestriction r, String unit) {
+ initInteger(key, val, descr, r);
+ initUnit(INTEGER_PREFIX + key, unit);
}
/**
- * Sets the restriction.
+ * Inits the integer.
*
* @param key the key
- * @param settingRestriction the setting restriction
+ * @param val the val
+ * @param descr the descr
+ * @param minValue the min value
+ * @param maxValue the max value
*/
- public synchronized void setRestriction(String key, SettingRestriction settingRestriction) {
- settingRestrictionPrefs.put(key, settingRestriction);
+ public void initInteger(String key, int val, String descr, int minValue, int maxValue) {
+ initInteger(key, val, descr, new VSIntegerPrefRestriction(minValue, maxValue));
}
/**
- * Sets the unit.
+ * Inits the integer plus unit.
*
* @param key the key
+ * @param val the val
+ * @param descr the descr
+ * @param minValue the min value
+ * @param maxValue the max value
* @param unit the unit
*/
- public synchronized void setUnit(String key, String unit) {
- units.put(key, unit);
+ public void initInteger(String key, int val, String descr, int minValue, int maxValue, String unit) {
+ initInteger(key, val, descr, minValue, maxValue);
+ initUnit(INTEGER_PREFIX + key, unit);
}
/**
- * Inits the string.
+ * Sets the integer.
*
* @param key the key
* @param val the val
- * @param descr the descr
*/
- public void initString(String key, String val, String descr) {
- initString(key, val);
- initDescription(STRING_PREFIX + key, descr);
+ public synchronized void setInteger(String key, Integer val) {
+ integerPrefs.put(key, val);
}
/**
- * Inits the boolean.
+ * Sets the integer.
*
* @param key the key
* @param val the val
- * @param descr the descr
*/
- public void initBoolean(String key, boolean val, String descr) {
- initBoolean(key, val);
- initDescription(BOOLEAN_PREFIX + key, descr);
+ public void setInteger(String key, int val) {
+ setInteger(key, new Integer(val));
}
+ /* Long methods */
+
/**
- * Inits the boolean unit.
+ * Gets the long.
*
* @param key the key
- * @param val the val
- * @param descr the descr
- * @param unit the unit
+ *
+ * @return the long
*/
- public void initBooleanInteger(String key, boolean val, String descr, String unit) {
- initBoolean(key, val, descr);
- setUnit(BOOLEAN_PREFIX + key, unit);
+ public long getLong(String key) {
+ return getLongObj(key).longValue();
}
/**
- * Inits the integer.
+ * Gets the long key set.
*
- * @param key the key
- * @param val the val
- * @param descr the descr
- * @param r the r
+ * @return the long key set
*/
- public void initLong(String key, Integer val, String descr, IntegerSettingRestriction r) {
- initLong(key, val);
- initDescription(INTEGER_PREFIX + key, descr);
- setRestriction(INTEGER_PREFIX + key, r);
+ public synchronized Set<String> getLongKeySet() {
+ return longPrefs.keySet();
}
/**
- * Inits the integer.
+ * Gets the long obj.
*
* @param key the key
- * @param val the val
- * @param descr the descr
- * @param minValue the min value
- * @param maxValue the max value
+ *
+ * @return the long obj
*/
- public void initLong(String key, Integer val, String descr, int minValue, int maxValue) {
- initLong(key, val, descr, new IntegerSettingRestriction(minValue, maxValue));
+ public synchronized Long getLongObj(String key) {
+ Long val = longPrefs.get(key);
+
+ if (val == null) {
+ System.err.println("Fatal: No such long config value \""
+ + key + "\"");
+ System.exit(1);
+ }
+
+ return val;
}
/**
- * Inits the integer.
+ * Inits the long.
*
* @param key the key
* @param val the val
- * @param descr the descr
- * @param r the r
*/
- public void initLong(String key, int val, String descr, IntegerSettingRestriction r) {
- initLong(key, new Integer(val), descr, r);
+ public synchronized void initLong(String key, Long val) {
+ if (!longPrefs.containsKey(key))
+ longPrefs.put(key, val);
}
/**
- * Inits the integer.
+ * Sets the long if unset.
*
* @param key the key
* @param val the val
- * @param descr the descr
- * @param minValue the min value
- * @param maxValue the max value
*/
- public void initLong(String key, int val, String descr, int minValue, int maxValue) {
- initLong(key, new Integer(val), descr, minValue, maxValue);
+ public void initLong(String key, long val) {
+ initLong(key, new Long(val));
}
/**
- * Inits the integer unit.
+ * Inits the long.
*
* @param key the key
* @param val the val
* @param descr the descr
- * @param minValue the min value
- * @param maxValue the max value
- * @param unit the unit
*/
- public void initLong(String key, int val, String descr, int minValue, int maxValue, String unit) {
- initLong(key, new Integer(val), descr, minValue, maxValue);
- setUnit(INTEGER_PREFIX + key, unit);
+ public void initLong(String key, long val, String descr) {
+ initLong(key, val);
+ initDescription(LONG_PREFIX + key, descr);
}
/**
- * Inits the integer unit.
+ * Inits the long unit.
*
* @param key the key
* @param val the val
* @param descr the descr
- * @param minValue the min value
- * @param maxValue the max value
* @param unit the unit
*/
- public void initLong(String key, int val, String descr, IntegerSettingRestriction sr, String unit) {
- initLong(key, new Integer(val), descr, sr);
- setUnit(INTEGER_PREFIX + key, unit);
+ public void initLong(String key, long val, String descr, String unit) {
+ initLong(key, val, descr);
+ initUnit(LONG_PREFIX + key, unit);
}
+
/**
- * Inits the long.
+ * Sets the long.
*
* @param key the key
* @param val the val
- * @param descr the descr
*/
- public void initLong(String key, Long val, String descr) {
- initLong(key, val);
- initDescription(LONG_PREFIX + key, descr);
+ public synchronized void setLong(String key, Long val) {
+ longPrefs.put(key, val);
}
/**
- * Inits the long.
+ * Sets the long.
*
* @param key the key
* @param val the val
- * @param descr the descr
*/
- public void initLong(String key, long val, String descr) {
- initLong(key, new Long(val), descr);
+ public void setLong(String key, long val) {
+ setLong(key, new Long(val));
}
+ /* String methods */
+
/**
- * Inits the long unit.
+ * Gets the string.
*
* @param key the key
- * @param val the val
- * @param descr the descr
- * @param unit the unit
+ *
+ * @return the string
*/
- public void initLong(String key, long val, String descr, String unit) {
- initLong(key, new Long(val), descr);
- setUnit(LONG_PREFIX + key, unit);
+ public synchronized String getString(String key) {
+ String val = stringPrefs.get(key);
+
+ if (val == null) {
+ System.err.println("Fatal: No such string config value \""
+ + key + "\"");
+ System.exit(1);
+ }
+
+ return val;
}
/**
- * Inits the float.
+ * Gets the string key set.
*
- * @param key the key
- * @param val the val
- * @param descr the descr
+ * @return the string key set
*/
- public void initFloat(String key, Float val, String descr) {
- initFloat(key, val);
- initDescription(FLOAT_PREFIX + key, descr);
+ public synchronized Set<String> getStringKeySet() {
+ return stringPrefs.keySet();
}
/**
- * Inits the float.
+ * Inits the string.
*
* @param key the key
* @param val the val
- * @param descr the descr
*/
- public void initFloat(String key, float val, String descr) {
- initFloat(key, new Float(val), descr);
+ public synchronized void initString(String key, String val) {
+ if (!stringPrefs.containsKey(key))
+ stringPrefs.put(key, val);
}
/**
- * Inits the float unit.
+ * Inits the string.
*
* @param key the key
* @param val the val
* @param descr the descr
- * @param unit the unit
*/
- public void initFloatInteger(String key, float val, String descr, String unit) {
- initFloat(key, new Float(val), descr);
- setUnit(FLOAT_PREFIX + key, unit);
+ public void initString(String key, String val, String descr) {
+ initString(key, val);
+ initDescription(STRING_PREFIX + key, descr);
}
-
/**
- * Inits the color.
+ * Sets the string.
*
* @param key the key
* @param val the val
- * @param descr the descr
*/
- public void initColor(String key, Color val, String descr) {
- initColor(key, val);
- initDescription(COLOR_PREFIX + key, descr);
+ public synchronized void setString(String key, String val) {
+ stringPrefs.put(key, val);
}
/**
@@ -971,7 +942,7 @@ public abstract class VSPrefs implements Serializable {
floatPrefs = (HashMap<String,Float>) objectInputStream.readObject();
integerPrefs = (HashMap<String,Integer>) objectInputStream.readObject();
longPrefs = (HashMap<String,Long>) objectInputStream.readObject();
- settingRestrictionPrefs = new HashMap<String,SettingRestriction>();
+ restrictions = new HashMap<String,VSPrefRestriction>();
stringPrefs = (HashMap<String,String>) objectInputStream.readObject();
units = (HashMap<String,String>) objectInputStream.readObject();
}
@@ -1019,10 +990,10 @@ public abstract class VSPrefs implements Serializable {
*/
public void copyIntegers(VSPrefs copyInto, String[] keys) {
for (String key : keys)
- copyInto.initLong(key,
- getInteger(key), getDescription(INTEGER_PREFIX + key),
- (IntegerSettingRestriction) getRestriction(INTEGER_PREFIX + key),
- getUnit(INTEGER_PREFIX + key));
+ copyInto.initInteger(key,
+ getInteger(key), getDescription(INTEGER_PREFIX + key),
+ (VSIntegerPrefRestriction) getRestriction(INTEGER_PREFIX + key),
+ getUnit(INTEGER_PREFIX + key));
}
/**
@@ -1046,9 +1017,9 @@ public abstract class VSPrefs implements Serializable {
*/
public void copyFloats(VSPrefs copyInto, String[] keys) {
for (String key : keys)
- copyInto.initFloatInteger(key, getFloat(key),
- getDescription(FLOAT_PREFIX + key),
- getUnit(FLOAT_PREFIX + key));
+ copyInto.initFloat(key, getFloat(key),
+ getDescription(FLOAT_PREFIX + key),
+ getUnit(FLOAT_PREFIX + key));
}
/**