de.cau.cs.kieler.sim.kiem.execution
Class JSONDataPool

java.lang.Object
  extended by de.cau.cs.kieler.sim.kiem.execution.JSONDataPool

public class JSONDataPool
extends Object

The Class JSONDataPool. It implements the "brain" of the execution manager and provides the execution manager with delta data information for it's delta observer DataComponents. This also is necessary for the history steps.

Rating proposed yellow
(2009-01-15)

Constructor Summary
JSONDataPool()
          Instantiates a new JSON data pool.
 
Method Summary
 JSONObject getData(String[] filterKeys)
          Gets the data.
 JSONObject getData(String[] filterKeys, long deltaPoolIndexTo)
          Gets the most current data.
 JSONObject getDeltaData(String[] filterKeys, long deltaPoolIndexFrom)
          Gets the delta data between (since) the deltaPoolIndexFrom and the deltaPoolIndexTo or the current index if the latter is not provided.
 JSONObject getDeltaData(String[] filterKeys, long deltaPoolIndexFrom, long deltaPoolIndexTo)
          Gets the delta data.
 long getPoolCounter()
          Gets the current pool counter.
 void putData(JSONObject newData)
          Puts a new JSONObject into the data pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSONDataPool

public JSONDataPool()
Instantiates a new JSON data pool.

Method Detail

getPoolCounter

public long getPoolCounter()
Gets the current pool counter.

Returns:
the pool counter

getData

public JSONObject getData(String[] filterKeys,
                          long deltaPoolIndexTo)
                   throws JSONException
Gets the most current data. This is the most efficient method to call since it just returns the current data pool contents. But be aware of the fact that the returned JSON object may have hundreds of values.

Parameters:
filterKeys - the filter keys, optional, may be null
deltaPoolIndexTo - the delta pool index to
Returns:
the JSONObject containing all data
Throws:
JSONException - a JSON exception

getData

public JSONObject getData(String[] filterKeys)
                   throws JSONException
Gets the data.

Parameters:
filterKeys - the filter keys
Returns:
the data
Throws:
JSONException - the JSON exception

getDeltaData

public JSONObject getDeltaData(String[] filterKeys,
                               long deltaPoolIndexFrom)
                        throws JSONException
Gets the delta data between (since) the deltaPoolIndexFrom and the deltaPoolIndexTo or the current index if the latter is not provided. It optionally filters the results if filterKeys is not null.

Parameters:
filterKeys - the filter keys, optional, may be null
deltaPoolIndexFrom - the delta pool index from
Returns:
the delta data
Throws:
JSONException - the JSON exception

getDeltaData

public JSONObject getDeltaData(String[] filterKeys,
                               long deltaPoolIndexFrom,
                               long deltaPoolIndexTo)
                        throws JSONException
Gets the delta data.

Parameters:
filterKeys - the filter keys
deltaPoolIndexFrom - the delta pool index from
deltaPoolIndexTo - the delta pool index to
Returns:
the delta data
Throws:
JSONException - the JSON exception

putData

public void putData(JSONObject newData)
             throws JSONException
Puts a new JSONObject into the data pool. It will also put the item into the delta pool list. If the list gets too large (according to DATA_DELTA_POOL_HISTORY_MAX) then we accumulate the history older than that into the object with the index 0. This allows us to play back up to DATA_DELTA_POOL_HISTORY_MAX data producers (*NOT* ticks).

Parameters:
newData - the new JSONObject to save
Throws:
JSONException - a JSON exception