uk.org.ogsadai.client.toolkit.activity.examples
Class DemoExternalInput

java.lang.Object
  |
  +--uk.org.ogsadai.client.toolkit.activity.RequestComponent
        |
        +--uk.org.ogsadai.client.toolkit.activity.Activity
              |
              +--uk.org.ogsadai.client.toolkit.activity.examples.DemoExternalInput

public class DemoExternalInput
extends Activity

Activity to demonstrate the use of an external input. An input stream is created, a number of integer blocks that will be written to the stream is specified, the activity sums these and outputs the total.

The activity has one dynamically generated input upon which a specific number of integer blocks are received and summed. The activity has one output - the sum of the values of each block.

Author:
The OGSA-DAI Project Team

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
          Copyright statement
private  int mNumInputBlocks
          Number of blocks that will be send to the external input
private  java.lang.String mStreamName
          Name of the external input - typically created server side
 
Fields inherited from class uk.org.ogsadai.client.toolkit.activity.Activity
 
Fields inherited from class uk.org.ogsadai.client.toolkit.activity.RequestComponent
 
Constructor Summary
DemoExternalInput(int nInputBlocks, java.lang.String streamName)
          Constructs the activity.
 
Method Summary
protected  java.lang.String generateXML()
          Generates the XML representing the activity.
 ActivityOutput getOutput()
          Gets the activity output - the sum of the values of each block.
 int getSum()
          Gets the sum of the values written to the input stream.
 
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

mNumInputBlocks

private int mNumInputBlocks
Number of blocks that will be send to the external input


mStreamName

private java.lang.String mStreamName
Name of the external input - typically created server side

Constructor Detail

DemoExternalInput

public DemoExternalInput(int nInputBlocks,
                         java.lang.String streamName)
Constructs the activity.

Parameters:
nInputBlocks - Number of input blocks of data the activity can expect to receive.
streamName - Input stream upon which data will be received.
Throws:
java.lang.IllegalArgumentException - If streamName is null.
Method Detail

getOutput

public ActivityOutput getOutput()
Gets the activity output - the sum of the values of each block.

Returns:
the activity output

getSum

public int getSum()
           throws DataFormatException,
                  NoActivityOutputException
Gets the sum of the values written to the input stream.

Returns:
sum of values written to input stream.
Throws:
NoActivityOutputException - if there is no output data or the data has not yet been processed to this output or the activity that generates this output has not yet been executed.
DataFormatException - if the output from the activity cannot be parsed into an integer.

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