|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uk.org.ogsadai.activity.Activity | +--uk.org.ogsadai.activity.sql.SQLResultToBytesActivity
Activity that converts a single entry in an SQL result set to a binary stream. The specified column value of the first row in the result set will be extracted from the input, converted into binary format and output as a sequence of byte arrays.
This activity is useful when extracting BLOBs from databases for further processing or delivery via other OGSA-DAI activities.
For information on this activity see the OGSA-DAI user doc:
OGSA-DAI/doc/interaction/activities/relational/sqlResultToBytes.html
Field Summary | |
static java.lang.String |
BLOCK_SIZE_ELEMENT
|
static java.lang.String |
COLUMN_INDEX_ELEMENT
|
private static java.lang.String |
COPYRIGHT_NOTICE
Copyright statement |
static int |
DEFAULT_BLOCK_SIZE
Default block size |
static java.lang.String |
FROM_ATTRIBUTE
|
private static DAILogger |
LOG
Logger object for logging in this class |
protected java.io.InputStream |
mBinaryInputStream
Input stream from which to read the binary data |
protected int |
mBlockSize
Size in bytes of output blocks |
protected int |
mColumnIndex
Index of the column to extract and convert to bytes |
protected BlockReader |
mInput
Reader that provides the activity's only input |
protected java.lang.String |
mInputStreamName
Name of the activity's only input stream |
protected BlockWriter |
mOutput
Write to which the activity's output is written |
protected java.lang.String |
mOutputStreamName
Name of the activity's only output stream |
static java.lang.String |
NAME_ATTRIBUTE
|
static java.lang.String |
OUTPUT_STREAM_ELEMENT
|
static java.lang.String |
RESULT_SET_ELEMENT
|
static java.lang.String |
VALUE_ATTRIBUTE
|
Fields inherited from class uk.org.ogsadai.activity.Activity |
mContext, mExternalInputs, mExternalOutputs, mInternalInputs, mInternalOutputs |
Constructor Summary | |
SQLResultToBytesActivity(org.w3c.dom.Element element)
Constructs an instance of the SQLResultToBytes activity. |
Method Summary | |
int |
getBlockSize()
Gets the block size which specifies the number of bytes that will be included in each output block. |
int |
getColumnIndex()
Gets the column index from which the binary data will be extracted. |
java.lang.String |
getInputStreamName()
Gets the activity's input stream name. |
java.lang.String |
getOutputStreamName()
Gets the activity's output stream name. |
protected java.sql.ResultSet |
getResultSet(BlockReader inputReader)
Gets the result set from the input reader. |
void |
initialise()
This method should be overridden by subclasses to perform any initialisation they require before the process
method invocations begin. |
protected void |
processBlock()
Performs an iteration of the processing of an activity. |
protected byte[] |
readBytesFromInputStream(java.io.InputStream is,
int blockSize)
Reads the specified number of bytes from the given input stream leaving the input stream intact for repeated calling. |
Methods inherited from class uk.org.ogsadai.activity.Activity |
cleanUp, connectsTo, createOutputPipe, getActivityConfiguration, getActivityName, getCause, getName, getObservableStatus, getProperties, getSession, getStatus, hasActivityConfiguration, hasProperties, process, processFirst, setActivityName, setCompleted, setError |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final java.lang.String COPYRIGHT_NOTICE
private static DAILogger LOG
public static final java.lang.String RESULT_SET_ELEMENT
public static final java.lang.String OUTPUT_STREAM_ELEMENT
public static final java.lang.String COLUMN_INDEX_ELEMENT
public static final java.lang.String BLOCK_SIZE_ELEMENT
public static final java.lang.String FROM_ATTRIBUTE
public static final java.lang.String NAME_ATTRIBUTE
public static final java.lang.String VALUE_ATTRIBUTE
public static final int DEFAULT_BLOCK_SIZE
protected java.lang.String mInputStreamName
protected BlockReader mInput
protected java.lang.String mOutputStreamName
protected BlockWriter mOutput
protected java.io.InputStream mBinaryInputStream
protected int mColumnIndex
protected int mBlockSize
Constructor Detail |
public SQLResultToBytesActivity(org.w3c.dom.Element element) throws ActivitySpecificationException, ActivityCreationException
The schema of the input XML element is defined in
sql_result_to_bytes.xsd
. An example is:
<sqlResultToBytes name="myActivityInstance"> <resultSet from="resultSetStream"/> <columnIndex value="1"/> <blockSize value="2000"/> <outputStream name="byteStream"/> </sqlResultToBytes>The
resultSet
element specifies the input to this
activity.
The columnIndex
element specifies which column
to tract the data from. The first column has an index of 1.
The blockSize
element is optional and if present specifies
the desired number of bytes in each output block.
The outputStream
element names the output stream that the
blocks will be written to.
- Parameters:
element
- parameters for the activity expressed in XML format.
- Throws:
ActivitySpecificationException
- if an error occurs due to the user's incorrect input.
ActivityCreationException
- if a error occurs beyond the specification of the input
parameters.
Method Detail |
public void initialise() throws ActivitySpecificationException, ActivityExecutionException
Activity
process
method invocations begin. This might be used for setting up
convenient fields to reference objects contained in the
context. It shouldn't be used for opening resources.
That should be done in processFirst
.
initialise
in class Activity
ActivityExecutionException
- If some system problem prevents the activity from
initialising.
ActivitySpecificationException
- If a problem with settings provided by a client prevents
the activity from initialising.public java.lang.String getInputStreamName()
public java.lang.String getOutputStreamName()
public int getColumnIndex()
public int getBlockSize()
protected void processBlock()
Activity
setCompleted
method to indicate that
processing is complete, or the setError
method if
an error occurs that will prevent the processing from
completing.
processBlock
in class Activity
protected byte[] readBytesFromInputStream(java.io.InputStream is, int blockSize) throws java.io.IOException
is
- the input stream to read.blockSize
- number of bytes to read from the stream.
java.io.IOException
- if an error occurs reading from the stream.protected java.sql.ResultSet getResultSet(BlockReader inputReader)
ResultSet
then an error will be set
and null
null will be returned. If there is no more data
setComplete
will be called.
inputReader
- input from which to read the result set object.
null
if there is no more blocks to read or
an error has occurred.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |