uk.org.ogsadai.client.toolkit.activity.indexedfiles
Class ReadFile

java.lang.Object
  |
  +--uk.org.ogsadai.client.toolkit.activity.RequestComponent
        |
        +--uk.org.ogsadai.client.toolkit.activity.Activity
              |
              +--uk.org.ogsadai.client.toolkit.activity.indexedfiles.ReadFile

public class ReadFile
extends Activity

This activity retrieves the contents of files. Files can either be plain text (in which case the start line and number of lines to be read can be specified) or binary (the default, in which case the start byte and number of bytes to be read can be specified).

The file path is relative to the root of a file system data service resource.

Alternatively the activity can receive input from another activity. The input must be a sequence of readFile activity elements. This method can be used to read and retrieve a number of files in sequence.

The activity has one output - the contents of the files that have been read. This can be base64 encoded, if required.

The getOutput method can be used to obtain the data output from the activity.


Field Summary
private static java.lang.String COPYRIGHT_NOTICE
          Copyright statement
private  boolean mBase64encode
          Is output to be base64 encoded?
private  java.lang.String mFilename
          Relative path of file to read
private  boolean mIsBinary
          Is the file to be read as bytes?
private  long mLength
          Number of lines/bytes to read
private  long mOffset
          Index of first line/byte to read
 
Fields inherited from class uk.org.ogsadai.client.toolkit.activity.Activity
 
Fields inherited from class uk.org.ogsadai.client.toolkit.activity.RequestComponent
 
Constructor Summary
ReadFile()
          Constructor.
ReadFile(ActivityOutput input)
          Constructor.
ReadFile(java.lang.String filename)
          Constructor.
 
Method Summary
protected  java.lang.String generateXML()
          Generates the XML representing the activity.
 java.lang.String getFilename()
          Gets relative path to file to be read.
 long getLength()
          Gets number of bytes (if isBinary is true) or lines to be read.
 long getOffset()
          Gets position of first byte (if isBinary is true) or line to be read.
 ActivityOutput getOutput()
          Get this activity's output - the data.
 boolean isBase64encoded()
          Indicates whether activity output is to be base64 encoded.
 boolean isBinary()
          Gets flag indicating if file is a binary file.
 void setBase64encode(boolean base64encode)
          Sets whether activity output is to be base64 encoded.
 void setBinary(boolean isBinary)
          Sets flag indicating if file is a binary file.
 void setFilename(java.lang.String filename)
          Sets relative path to file to be read.
 void setInput(ActivityOutput input)
          Sets the input of this activity to be the output from another activity that will provide the data.
 void setLength(long length)
          Sets number of bytes (if isBinary is true) or lines to be read.
 void setOffset(long offset)
          Sets the position of the first byte (if isBinary is true) or the first line to be read.
 
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

mFilename

private java.lang.String mFilename
Relative path of file to read


mOffset

private long mOffset
Index of first line/byte to read


mIsBinary

private boolean mIsBinary
Is the file to be read as bytes?


mLength

private long mLength
Number of lines/bytes to read


mBase64encode

private boolean mBase64encode
Is output to be base64 encoded?

Constructor Detail

ReadFile

public ReadFile()
Constructor.


ReadFile

public ReadFile(java.lang.String filename)
Constructor.

Parameters:
filename - Relative path to file to read.

ReadFile

public ReadFile(ActivityOutput input)
Constructor.

Parameters:
input - Output from another activity that provides input to this activity. This will only be used if there is no file name (i.e. getFilename is null).
Throws:
java.lang.IllegalArgumentException - If input is null.
Method Detail

setFilename

public void setFilename(java.lang.String filename)
Sets relative path to file to be read.

Parameters:
filename - Relative path to file to read.

getFilename

public java.lang.String getFilename()
Gets relative path to file to be read.

Returns:
file

setBinary

public void setBinary(boolean isBinary)
Sets flag indicating if file is a binary file. The flag is not used if there is no file name (i.e. getFilename is null).

Parameters:
isBinary - true if file is to be treated as binary and false otherwise.

isBinary

public boolean isBinary()
Gets flag indicating if file is a binary file.

Returns:
true if file is to be treated as binary and false otherwise.

setLength

public void setLength(long length)
Sets number of bytes (if isBinary is true) or lines to be read. The value can be set to -1 to read the filed from offset to the end of file. The value is not used if there is no file name (i.e. getFilename is null).

Parameters:
length - Number of bytes or lines, or -1 if reading to the end of the file
Throws:
java.lang.IllegalArgumentException - if length < -1.

getLength

public long getLength()
Gets number of bytes (if isBinary is true) or lines to be read.

Returns:
number of bytes or lines.

setOffset

public void setOffset(long offset)
Sets the position of the first byte (if isBinary is true) or the first line to be read. The value is not used if there is no file name (i.e. getFilename is null).

Parameters:
offset - Position of first byte or line, starting at 0.
Throws:
java.lang.IllegalArgumentException - if offset < 0.

getOffset

public long getOffset()
Gets position of first byte (if isBinary is true) or line to be read.

Returns:
offset

isBase64encoded

public boolean isBase64encoded()
Indicates whether activity output is to be base64 encoded.

Returns:
true if the output will be base64 encoded, false otherwise.

setBase64encode

public void setBase64encode(boolean base64encode)
Sets whether activity output is to be base64 encoded.

Parameters:
base64encode - true if the output will be base64 encoded, false otherwise.

setInput

public void setInput(ActivityOutput input)
Sets the input of this activity to be the output from another activity that will provide the data.

Parameters:
input - Output from another activity that provides input to this activity. This will only be used if there is no file name (i.e. getFilename is null).
Throws:
java.lang.IllegalArgumentException - If input is null.

getOutput

public ActivityOutput getOutput()
Get this activity's output - the data.

Returns:
this activity's 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