superwaba.ext.xplat.util.props
Class Properties

java.lang.Object
  |
  +--superwaba.ext.xplat.util.props.Properties
Direct Known Subclasses:
Options

public class Properties
extends java.lang.Object

Class used to store properties pairs (key,value). A hashtable is used to store them. Currently, the key must be a String and the value must be a Value (Properties.Str, Properties.Int, Properties.Double, Properties.Long, Properties.Boolean. The properties can be saved and loaded to/from a DataStream.


Inner Class Summary
static class Properties.Boolean
          Implements a value of type boolean
static class Properties.Double
          Implements a value of type double
static class Properties.Int
          Implements a value of type int
static class Properties.Long
          Implements a value of type long
static class Properties.Str
          Implements a value of type String
static class Properties.Value
          Represents a generic value that can be stored here.
 
Field Summary
static int MAX_PROPS
          Avoids that the load method gets into an infinite loop if the file is empty or corrupted.
 
Constructor Summary
Properties()
           
Properties(java.lang.String[] keys, Properties.Value[] values)
          Stores the given keys/values pairs in a new Properties.
 
Method Summary
 void clear()
          Clears this property
 Properties.Value get(java.lang.String key)
          Get the value given the key from the hashtable that stores the properties.
 Vector getKeys()
          Returns a Vector with the current keys
 void load(DataStream ds)
          Load all properties from the given DataStream.
 void put(java.lang.String key, Properties.Value v)
          Put the given key/value pair in the hashtable that stores the properties.
 void remove(java.lang.String key)
          Remove a value from the property
 void save(DataStream ds)
          Save all properties in the given DataStream
 int size()
          Returns the number of properties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_PROPS

public static int MAX_PROPS
Avoids that the load method gets into an infinite loop if the file is empty or corrupted. This constant limits the number of properties to 1000. If you are saving more than 1000 props, just change this max value.
Constructor Detail

Properties

public Properties()

Properties

public Properties(java.lang.String[] keys,
                  Properties.Value[] values)
Stores the given keys/values pairs in a new Properties.
Method Detail

put

public void put(java.lang.String key,
                Properties.Value v)
Put the given key/value pair in the hashtable that stores the properties.

get

public Properties.Value get(java.lang.String key)
Get the value given the key from the hashtable that stores the properties.

size

public int size()
Returns the number of properties

getKeys

public Vector getKeys()
Returns a Vector with the current keys

clear

public void clear()
Clears this property

remove

public void remove(java.lang.String key)
Remove a value from the property

save

public void save(DataStream ds)
Save all properties in the given DataStream

load

public void load(DataStream ds)
Load all properties from the given DataStream. Before calling this method, be sure that there's something to be read (ie, that the file is not empty), otherwise it may run in an infinite loop and will freeze your device.