From d04ee66ac7a02e7e226478bdc0eebdd97f060e14 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 26 May 2008 17:39:03 +0000 Subject: Vector type introduced @ VSPrefs. --- sources/prefs/VSPrefs.java | 95 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) (limited to 'sources/prefs/VSPrefs.java') diff --git a/sources/prefs/VSPrefs.java b/sources/prefs/VSPrefs.java index dd274b9..915d8e3 100644 --- a/sources/prefs/VSPrefs.java +++ b/sources/prefs/VSPrefs.java @@ -25,6 +25,9 @@ public abstract class VSPrefs implements Serializable { /** The Constant INTEGER_PREFIX. */ public static final String INTEGER_PREFIX = "Integer: "; + /** The Constant VECTOR_PREFIX. */ + public static final String VECTOR_PREFIX = "Vector: "; + /** The Constant LONG_PREFIX. */ public static final String LONG_PREFIX = "Long: "; @@ -40,6 +43,9 @@ public abstract class VSPrefs implements Serializable { /** The integer prefs. */ private HashMap integerPrefs; + /** The integer vector prefs. */ + private HashMap> vectorPrefs; + /** The long prefs. */ private HashMap longPrefs; @@ -160,6 +166,7 @@ public abstract class VSPrefs implements Serializable { descriptionPrefs = new HashMap(); floatPrefs = new HashMap(); integerPrefs = new HashMap(); + vectorPrefs = new HashMap>(); longPrefs = new HashMap(); restrictions = new HashMap(); stringPrefs = new HashMap(); @@ -176,6 +183,7 @@ public abstract class VSPrefs implements Serializable { colorPrefs.clear(); floatPrefs.clear(); integerPrefs.clear(); + vectorPrefs.clear(); longPrefs.clear(); stringPrefs.clear(); booleanPrefs.clear(); @@ -707,6 +715,81 @@ public abstract class VSPrefs implements Serializable { setInteger(key, new Integer(val)); } + /* Integer vector methods */ + + /** + * Gets the integer key set. + * + * @return the integer key set + */ + public synchronized Set getVectorKeySet() { + return vectorPrefs.keySet(); + } + + /** + * Gets the integer obj. + * + * @param key the key + * + * @return the integer obj + */ + public synchronized Vector getVector(String key) { + Vector val = vectorPrefs.get(key); + + if (val == null) { + System.err.println("Fatal: No such integer config value \"" + + key + "\""); + System.exit(1); + } + + return val; + } + + /** + * Inits the integer. + * + * @param key the key + * @param val the val + */ + public synchronized void initVector(String key, Vector val) { + if (!vectorPrefs.containsKey(key)) + setVector(key, val); + } + + /** + * Inits the integer vector. + * + * @param key the key + * @param val the val + * @param descr the descr + */ + public void initVector(String key, Vector val, String descr) { + initVector(key, val); + initDescription(VECTOR_PREFIX + key, descr); + } + + /** + * Inits the integer vector plus unit. + * + * @param key the key + * @param val the val + * @param descr the descr + */ + public void initVector(String key, Vector val, String descr, String unit) { + initVector(key, val, descr); + initUnit(VECTOR_PREFIX + key, unit); + } + + /** + * Sets the integer vector. + * + * @param key the key + * @param val the val + */ + public synchronized void setVector(String key, Vector val) { + vectorPrefs.put(key, val); + } + /* Long methods */ /** @@ -921,6 +1004,7 @@ public abstract class VSPrefs implements Serializable { objectOutputStream.writeObject(colorPrefs); objectOutputStream.writeObject(floatPrefs); objectOutputStream.writeObject(integerPrefs); + objectOutputStream.writeObject(vectorPrefs); objectOutputStream.writeObject(longPrefs); objectOutputStream.writeObject(stringPrefs); objectOutputStream.writeObject(units); @@ -941,6 +1025,7 @@ public abstract class VSPrefs implements Serializable { descriptionPrefs = new HashMap(); floatPrefs = (HashMap) objectInputStream.readObject(); integerPrefs = (HashMap) objectInputStream.readObject(); + vectorPrefs = (HashMap>) objectInputStream.readObject(); longPrefs = (HashMap) objectInputStream.readObject(); restrictions = new HashMap(); stringPrefs = (HashMap) objectInputStream.readObject(); @@ -1071,6 +1156,13 @@ public abstract class VSPrefs implements Serializable { descr += key + "=" + getInteger(key) + "; "; } + set = getVectorKeySet(); + if (set.size() > 0) { + descr += VECTOR_PREFIX; + for (String key : set) + descr += key + "=" + getVector(key) + "; "; + } + set = getLongKeySet(); if (set.size() > 0) { descr += LONG_PREFIX; @@ -1129,6 +1221,9 @@ public abstract class VSPrefs implements Serializable { if (!integerPrefs.isEmpty()) return false; + if (!vectorPrefs.isEmpty()) + return false; + if (!longPrefs.isEmpty()) return false; -- cgit v1.2.3