uk.org.ogsadai.client.toolkit.activity.misc
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.misc.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.

This activity has one optional input - data from the output of another activity - and one output - the data in the store.

Author:
The OGSA-DAI Project Team

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
          Copyright statement
private static int FROM_ACTIVITY
          Data will come from the output of another activity
private static int HARD_CODED
          Data is provided within this activity
private  java.util.List mItems
          Data - only if source for data is HARD_CODED
private  int mType
          Source for data - one of NONE_SPECIFIED, FROM_ACTIVITY or HARD_CODED
private static int NONE_SPECIFIED
          No source for the data has been specified
 
Fields inherited from class uk.org.ogsadai.client.toolkit.activity.Activity
 
Fields inherited from class uk.org.ogsadai.client.toolkit.activity.RequestComponent
 
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()
          Generates the XML representing the activity.
 ActivityOutput getOutput()
          Gets the activity's only output - the data in the store.
 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, getInputParameters, getOutputParameters, getOutputs, replaceSpecialCharacters, setDataResourceID, setInput
 
Methods inherited from class uk.org.ogsadai.client.toolkit.activity.RequestComponent
getDataService, getName, getSession, setDataService, setSession
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT_NOTICE

private static final java.lang.String COPYRIGHT_NOTICE
Copyright statement

See Also:
Constant Field Values

NONE_SPECIFIED

private static final int NONE_SPECIFIED
No source for the data has been specified

See Also:
Constant Field Values

FROM_ACTIVITY

private static final int FROM_ACTIVITY
Data will come from the output of another activity

See Also:
Constant Field Values

HARD_CODED

private static final int HARD_CODED
Data is provided within this activity

See Also:
Constant Field Values

mType

private int mType
Source for data - one of NONE_SPECIFIED, FROM_ACTIVITY or HARD_CODED


mItems

private java.util.List mItems
Data - only if source for data is HARD_CODED

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 that will be hard coded into the activity.
Throws:
java.lang.IllegalArgumentException - If items is null.

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
Throws:
java.lang.IllegalArgumentException - If input is null.
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.IllegalStateException - If some hard-coded data items have already been provided.
java.lang.IllegalArgumentException - If input is null.

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.
java.lang.IllegalArgumentException - If items is null.

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.
java.lang.IllegalArgumentException - If item is null.

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.
java.lang.IllegalArgumentException - If items is null.

getOutput

public ActivityOutput getOutput()
Gets the activity's only output - the data in the store.

Returns:
the activity output.

generateXML

protected java.lang.String generateXML()
Description copied from class: RequestComponent
Generates the XML representing the activity. This XML can then be inserted into a perform document that is sent to a data service.

Specified by:
generateXML in class Activity
Returns:
the XML for the activity