dk.klafbang.tincpn.animation.plugin
Class DataStore

java.lang.Object
  extended by dk.klafbang.tincpn.animation.plugin.DataStore

public class DataStore
extends java.lang.Object

Simple storage for simple data-types.

Often, you would like to store some data for keeping your animation up to date, or your would tike to gather data for a log or statistics. ML is not well-suited for this, so this animation object provides this service.

Apart from being usefull in itself, this animation object shows how easy it is to communicate with general Java objects.

Since:
1.0
Author:
Michael Westergaard

Constructor Summary
DataStore(java.lang.String name, java.lang.String id)
          Constructs a DataStore object.
 
Method Summary
 int decrement(java.lang.String key)
          Decrement an integer in the storage with the specified key.
 boolean flipBoolean(java.lang.String key)
          Flip a boolean value in the storage with the given key.
 boolean getBoolean(java.lang.String key)
          Get a boolean value from the storage with the specified key.
 java.lang.String getString(java.lang.String key)
          Look up the (string) value for a given key.
 int increment(java.lang.String key)
          Increment an integer in the storage with the specified key.
 boolean putBoolean(java.lang.String key, boolean value)
          Set a boolean value in the storage with the given key.
 java.lang.String putString(java.lang.String key, java.lang.String value)
          Put a string value into the storage with the specified key.
 void reset()
          Reset the store to its initial value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataStore

public DataStore(java.lang.String name,
                 java.lang.String id)
Constructs a DataStore object.

Parameters:
name - The name of the store
id -
Method Detail

reset

public void reset()
Reset the store to its initial value.


putString

public java.lang.String putString(java.lang.String key,
                                  java.lang.String value)
Put a string value into the storage with the specified key.

Parameters:
key - the key
value - the value
Returns:
the previous value (or the empty string if no value was previously defined)

getString

public java.lang.String getString(java.lang.String key)
Look up the (string) value for a given key.

Parameters:
key - the key
Returns:
the value (or the empty string if no value was previously defined)

increment

public int increment(java.lang.String key)
Increment an integer in the storage with the specified key.

Parameters:
key - the key
Returns:
the previous value

decrement

public int decrement(java.lang.String key)
Decrement an integer in the storage with the specified key.

Parameters:
key - the key
Returns:
the previous value

putBoolean

public boolean putBoolean(java.lang.String key,
                          boolean value)
Set a boolean value in the storage with the given key.

Parameters:
key - the key
value - the value to store
Returns:
the previous value (or false if the value was previously undefined)

getBoolean

public boolean getBoolean(java.lang.String key)
Get a boolean value from the storage with the specified key.

Parameters:
key - the key
Returns:
the value

flipBoolean

public boolean flipBoolean(java.lang.String key)
Flip a boolean value in the storage with the given key.

Parameters:
key - the key
Returns:
the previous value