uk.org.ogsadai.client.toolkit.activity.transform
Class DataStore

java.lang.Object
  |
  +--uk.org.ogsadai.client.toolkit.activity.RequestComponent
        |
        +--uk.org.ogsadai.client.toolkit.activity.Activity
              |
              +--uk.org.ogsadai.client.toolkit.activity.transform.DataStore

public class DataStore
extends Activity

A data store to provide data for other activities. There are two ways in which it can be used:

The two constructors which take arguments can be used to cause the activity behave in either of these ways. Use of the constructor which takes no arguments needs to be used in conjunction with the setItems, addItem or addItems methods (to force the data store to behave in the former manner); or the setInput method (to force the data store to behave in the latter manner).

Note that data can be directly provided in the form of Objects. These are interpreted as data items by using the return value of their toString() method.

Author:
The OGSA-DAI Project Team

Constructor Summary
DataStore()
          Initialise a new data store.
DataStore(ActivityOutput input)
          Initialise a new data store to act as a buffer of data from another activity's output.
DataStore(java.util.List items)
          Initialise a new data store to act as a cache of data items, initially containing the given items.
 
Method Summary
 void addItem(java.lang.Object item)
          Add an item to the list of items in the data store.
 void addItems(java.util.List items)
          Add a list of items to the existing list of items in the data store
protected  java.lang.String generateXML()
          Generate a perform document with appropriate parameters.
 ActivityOutput getOutput()
          Gets the activity's only output.
 void setInput(ActivityOutput input)
          Specify the output of another activity, from which the data will be obtained.
 void setItems(java.util.List items)
          Specify the list of items which constitute this data store.
 
Methods inherited from class uk.org.ogsadai.client.toolkit.activity.Activity
addInput, addOutput, addOutputs, getDataResourceID, getDataServiceStub, getInputParameters, getOutputParameters, getOutputs, replaceSpecialCharacters, setDataResourceID, setDataServiceStub, setInput
 
Methods inherited from class uk.org.ogsadai.client.toolkit.activity.RequestComponent
getName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataStore

public DataStore()
Initialise a new data store. Use of the setItems, addItem or addItems methods must be used to cause the data store to behave as a cache of data items; or the setInput method must be used to cause the data store to behave as a buffer of data from another activity.


DataStore

public DataStore(java.util.List items)
Initialise a new data store to act as a cache of data items, initially containing the given items.

Parameters:
items - a list of Objects to be used in the data store

DataStore

public DataStore(ActivityOutput input)
Initialise a new data store to act as a buffer of data from another activity's output.

Parameters:
input - the output from another activity
Method Detail

setInput

public void setInput(ActivityOutput input)
Specify the output of another activity, from which the data will be obtained.

Parameters:
input - the output from another activity
Throws:
java.lang.IllegalArgumentException - if the argument is null
java.lang.IllegalStateException - if some data items have already been provided

setItems

public void setItems(java.util.List items)
Specify the list of items which constitute this data store.

Parameters:
items - the list of items
Throws:
java.lang.IllegalStateException - if the output of another activity has already been specified

addItem

public void addItem(java.lang.Object item)
Add an item to the list of items in the data store.

Parameters:
item - the item to add
Throws:
java.lang.IllegalStateException - if the output of another activity has already been specified

addItems

public void addItems(java.util.List items)
Add a list of items to the existing list of items in the data store

Parameters:
items - the items to add
Throws:
java.lang.IllegalStateException - if the output of another activity has already been specified

getOutput

public ActivityOutput getOutput()
Gets the activity's only output.

Returns:
the activity output.

generateXML

protected java.lang.String generateXML()
Generate a perform document with appropriate parameters.

Specified by:
generateXML in class Activity
Returns:
the XML for the activity
Throws:
java.lang.IllegalStateException - if no input or no items have been provided