jas.util
Class UserProperties

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--java.util.Properties
                    |
                    +--jas.util.UserProperties
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable

public final class UserProperties
extends java.util.Properties

This class is used to store user prorerties. There is one instance for the application. The UserProperties object used is available from the Application object using a getUserProperties() method.

See Also:
Application, Application.getUserProperties(), Serialized Form

Inner classes inherited from class java.util.Map
java.util.Map.Entry
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
UserProperties()
          The Application object will create an instance for the application and save it just before the application closes.
 
Method Summary
 boolean getBoolean(java.lang.String key, boolean def)
           
 java.awt.Color getColor(java.lang.String key, java.awt.Color def)
           
 float getFloat(java.lang.String key, float def)
           
 int getInteger(java.lang.String key)
           
 int getInteger(java.lang.String key, int def)
           
 java.awt.Rectangle getRectangle(java.lang.String key, java.awt.Rectangle def)
           
 java.lang.String getString(java.lang.String key, java.lang.String def)
           
 java.lang.String[] getStringArray(java.lang.String key, java.lang.String[] def)
           
 void save()
          Saves the properties.
 void setBoolean(java.lang.String key, boolean value)
           
 void setColor(java.lang.String key, java.awt.Color c)
           
 void setFloat(java.lang.String key, float f)
           
 void setInteger(java.lang.String key, int i)
           
 void setRectangle(java.lang.String key, java.awt.Rectangle rect)
           
 void setString(java.lang.String key, java.lang.String s)
           
 void setStringArray(java.lang.String key, java.lang.String[] sa)
           
static java.lang.String[] updateStringArray(java.lang.String[] oldArray, java.lang.String newString)
          This is a utility method for updating a string array of recently used items.
static java.lang.String[] updateStringArray(java.lang.String[] oldArray, java.lang.String newString, int nStored)
          This is a utility method for updating a string array of recently used items.
 java.lang.String[] updateStringArray(java.lang.String[] oldArray, java.lang.String newString, java.lang.String lengthKey)
          This is a utility method for updating a string array of recently used items.
 
Methods inherited from class java.util.Properties
getProperty, getProperty, list, list, load, propertyNames, save, setProperty, store
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UserProperties

public UserProperties()
The Application object will create an instance for the application and save it just before the application closes. Therefore, you should not have to use the constructor yourself. The UserProperties object used is available from the Application object using a getUserProperties() method.
See Also:
Application, Application.getUserProperties()
Method Detail

getRectangle

public java.awt.Rectangle getRectangle(java.lang.String key,
                                       java.awt.Rectangle def)
Parameters:
key - the key used to store this property
def - a default in case the property cannot be retrieved

setRectangle

public void setRectangle(java.lang.String key,
                         java.awt.Rectangle rect)
Parameters:
key - the key used to store this property
rect - the value to store

getColor

public java.awt.Color getColor(java.lang.String key,
                               java.awt.Color def)
Parameters:
key - the key used to store this property
def - a default in case the property cannot be retrieved

setColor

public void setColor(java.lang.String key,
                     java.awt.Color c)
Parameters:
key - the key used to store this property
c - the value to store

getStringArray

public java.lang.String[] getStringArray(java.lang.String key,
                                         java.lang.String[] def)
Parameters:
key - the key used to store this property
def - a default in case the property cannot be retrieved

setStringArray

public void setStringArray(java.lang.String key,
                           java.lang.String[] sa)
Parameters:
key - the key used to store this property
sa - the value to store

getString

public java.lang.String getString(java.lang.String key,
                                  java.lang.String def)
Parameters:
key - the key used to store this property
def - a default in case the property cannot be retrieved

setString

public void setString(java.lang.String key,
                      java.lang.String s)
Parameters:
key - the key used to store this property
s - the value to store

getBoolean

public boolean getBoolean(java.lang.String key,
                          boolean def)
Parameters:
key - the key used to store this property
def - a default in case the property cannot be retrieved

setBoolean

public void setBoolean(java.lang.String key,
                       boolean value)
Parameters:
key - the key used to store this property
value - the value to store

getInteger

public int getInteger(java.lang.String key)
               throws java.lang.NumberFormatException
Parameters:
key - the key used to store this property
Throws:
java.lang.NumberFormatException - if the property retrieved cannot be converted to int

getInteger

public int getInteger(java.lang.String key,
                      int def)
Parameters:
key - the key used to store this property
def - a default in case the property cannot be retrieved

setFloat

public void setFloat(java.lang.String key,
                     float f)
Parameters:
key - the key used to store this property
f - the value to store

getFloat

public float getFloat(java.lang.String key,
                      float def)
Parameters:
key - the key used to store this property
def - a default in case the property cannot be retrieved

setInteger

public void setInteger(java.lang.String key,
                       int i)
Parameters:
key - the key used to store this property
i - the value to store

save

public void save()
          throws java.io.IOException
Saves the properties. The application does this for you just before closing, so you don't have to call this method.

updateStringArray

public static java.lang.String[] updateStringArray(java.lang.String[] oldArray,
                                                   java.lang.String newString)
This is a utility method for updating a string array of recently used items. Supply it with an old array and a new item. If the new item was already in the old array, then it is simply moved to the beginning. If it was not in the old array then it is placed at the front and the other items are shuffled back. The method will return an array with a maximum size of 4.
Parameters:
oldArray - the array to update (may safely be null)
newString - the new item to include
Returns:
the updated array

updateStringArray

public java.lang.String[] updateStringArray(java.lang.String[] oldArray,
                                            java.lang.String newString,
                                            java.lang.String lengthKey)
This is a utility method for updating a string array of recently used items. Supply it with an old array and a new item. If the new item was already in the old array, then it is simply moved to the beginning. If it was not in the old array then it is placed at the front and the other items are shuffled back. The method will return an array with a maximum size defined by the integer stored by the given key, or 4 if such an integer cannot be found.
Parameters:
oldArray - the array to update (may safely be null)
newString - the new item to include
lengthKey - the key used to find the maximum length of the resulting array
Returns:
the updated array

updateStringArray

public static java.lang.String[] updateStringArray(java.lang.String[] oldArray,
                                                   java.lang.String newString,
                                                   int nStored)
This is a utility method for updating a string array of recently used items. Supply it with an old array and a new item. If the new item was already in the old array, then it is simply moved to the beginning. If it was not in the old array then it is placed at the front and the other items are shuffled back. The method will return an array of a maximum size given by the nStored parameter.
Parameters:
oldArray - the array to update (may safely be null)
newString - the new item to include
nStored - the maximum size of the updated array
Returns:
the updated array