toxi.util.datatypes
Class TypedProperties

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by java.util.Hashtable<java.lang.Object,java.lang.Object>
          extended by java.util.Properties
              extended by toxi.util.datatypes.TypedProperties
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.Object,java.lang.Object>

public class TypedProperties
extends java.util.Properties

Convenience wrapper providing typed access to Java Properties files.

See Also:
Serialized Form

Field Summary
static java.lang.String DELIM
           
 
Constructor Summary
TypedProperties()
           
 
Method Summary
 boolean getBoolean(java.lang.String id, boolean defaultState)
          Returns a property as boolean.
 byte[] getByteArray(java.lang.String id)
          Shorthand wrapper for getByteArray(String, byte[]) automatically supplying an empty byte[] as default value.
 byte[] getByteArray(java.lang.String id, byte[] defaultArray)
          Returns a comma delimited property value as byte[] array.
 float getFloat(java.lang.String id, float defaultValue)
          Returns a property as float.
 float[] getFloatArray(java.lang.String id)
          Shorthand wrapper for getFloatArray(String, float[]) automatically supplying an empty float[] array as default value.
 float[] getFloatArray(java.lang.String id, float[] defaultArray)
          Returns a comma delimited property value as float[] array.
 int getHexInt(java.lang.String id, int defaultValue)
          Returns a hexadecimal property as integer
 int getInt(java.lang.String id, int defaultValue)
          Returns a property as integer.
 int[] getIntArray(java.lang.String id)
          Shorthand wrapper for {getIntArray(String, int[]) automatically supplying an empty int[] array as default value.
 int[] getIntArray(java.lang.String id, int[] defaultArray)
          Returns a comma delimited property value as int[] array.
 java.lang.String[] getStringArray(java.lang.String id)
           
 java.lang.String[] getStringArray(java.lang.String id, java.lang.String[] defaultArray)
           
 boolean load(java.lang.String path)
          Attempts to load properties from the specified (absolute) file path (In Processing use sketchPath() or dataPath() to build absolute path).
 java.util.HashMap<java.lang.String,java.lang.String> toHashMap()
           
 
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, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, remove, size, toString, values
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DELIM

public static final java.lang.String DELIM
See Also:
Constant Field Values
Constructor Detail

TypedProperties

public TypedProperties()
Method Detail

getBoolean

public boolean getBoolean(java.lang.String id,
                          boolean defaultState)
Returns a property as boolean.

Parameters:
id - property name
defaultState -
Returns:
prop value

getByteArray

public byte[] getByteArray(java.lang.String id)
Shorthand wrapper for getByteArray(String, byte[]) automatically supplying an empty byte[] as default value.

Parameters:
id -
Returns:
prop values as array

getByteArray

public byte[] getByteArray(java.lang.String id,
                           byte[] defaultArray)
Returns a comma delimited property value as byte[] array. Non-byte values will be ignored.

Parameters:
id - prop name
Returns:
prop values as array

getFloat

public float getFloat(java.lang.String id,
                      float defaultValue)
Returns a property as float.

Parameters:
id -
defaultValue -
Returns:
prop value

getFloatArray

public float[] getFloatArray(java.lang.String id)
Shorthand wrapper for getFloatArray(String, float[]) automatically supplying an empty float[] array as default value.

Parameters:
id -
Returns:
prop values as array

getFloatArray

public float[] getFloatArray(java.lang.String id,
                             float[] defaultArray)
Returns a comma delimited property value as float[] array.

Parameters:
id - prop name
Returns:
prop items as array

getHexInt

public int getHexInt(java.lang.String id,
                     int defaultValue)
Returns a hexadecimal property as integer

Parameters:
id - prop name
defaultValue -
Returns:
prop value

getInt

public int getInt(java.lang.String id,
                  int defaultValue)
Returns a property as integer.

Parameters:
id - property name
defaultValue -
Returns:
prop value

getIntArray

public int[] getIntArray(java.lang.String id)
Shorthand wrapper for {getIntArray(String, int[]) automatically supplying an empty int[] array as default value.

Parameters:
id -
Returns:
prop values as array

getIntArray

public int[] getIntArray(java.lang.String id,
                         int[] defaultArray)
Returns a comma delimited property value as int[] array. Non-integer items will be ignored.

Parameters:
id - prop name
Returns:
prop items as array

getStringArray

public java.lang.String[] getStringArray(java.lang.String id)

getStringArray

public java.lang.String[] getStringArray(java.lang.String id,
                                         java.lang.String[] defaultArray)

load

public boolean load(java.lang.String path)
Attempts to load properties from the specified (absolute) file path (In Processing use sketchPath() or dataPath() to build absolute path).

Parameters:
path - config file
Returns:
true, if successful.

toHashMap

public java.util.HashMap<java.lang.String,java.lang.String> toHashMap()