jas2.util
Class UserProperties
- java.lang.Object
-
- java.util.Dictionary<K,V>
-
- java.util.Hashtable<java.lang.Object,java.lang.Object>
-
- java.util.Properties
-
- jas2.util.UserProperties
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.Object,java.lang.Object>
public class UserProperties extends java.util.PropertiesThis 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 agetUserProperties()method.
-
-
Constructor Summary
Constructors Constructor and Description UserProperties()The Application object will create an instance for the application and save it just before the application closes.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description booleangetBoolean(java.lang.String key, boolean def)java.awt.ColorgetColor(java.lang.String key, java.awt.Color def)floatgetFloat(java.lang.String key, float def)intgetInteger(java.lang.String key)intgetInteger(java.lang.String key, int def)java.awt.RectanglegetRectangle(java.lang.String key, java.awt.Rectangle def)java.lang.StringgetString(java.lang.String key, java.lang.String def)java.lang.String[]getStringArray(java.lang.String key, java.lang.String[] def)static UserPropertiesgetUserProperties()voidsave()Saves the properties.voidsetBoolean(java.lang.String key, boolean value)voidsetColor(java.lang.String key, java.awt.Color c)voidsetFloat(java.lang.String key, float f)voidsetInteger(java.lang.String key, int i)voidsetRectangle(java.lang.String key, java.awt.Rectangle rect)voidsetString(java.lang.String key, java.lang.String s)voidsetStringArray(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, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNames
-
Methods inherited from class java.util.Hashtable
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keys, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, toString, values
-
-
-
-
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 agetUserProperties()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 propertydef- 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 propertyrect- 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 propertydef- 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 propertyc- 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 propertydef- 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 propertysa- 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 propertydef- 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 propertys- the value to store
-
getBoolean
public boolean getBoolean(java.lang.String key, boolean def)- Parameters:
key- the key used to store this propertydef- 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 propertyvalue- 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 toint
-
getInteger
public int getInteger(java.lang.String key, int def)- Parameters:
key- the key used to store this propertydef- 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 propertyf- the value to store
-
getFloat
public float getFloat(java.lang.String key, float def)- Parameters:
key- the key used to store this propertydef- 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 propertyi- the value to store
-
save
public void save() throws java.io.IOExceptionSaves the properties. The application does this for you just before closing, so you don't have to call this method.- Throws:
java.io.IOException
-
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 benull)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 benull)newString- the new item to includelengthKey- 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 thenStoredparameter.- Parameters:
oldArray- the array to update (may safely benull)newString- the new item to includenStored- the maximum size of the updated array- Returns:
- the updated array
-
getUserProperties
public static UserProperties getUserProperties()
-
-
DataMelt 3.0 © DataMelt by jWork.ORG