|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--uk.org.ogsadai.engine.Activity
|
+--uk.org.ogsadai.activity.files.AbstractFileActivity
|
+--uk.org.ogsadai.activity.files.FileWritingActivity
The Activity which allows writing to a file. The file may be a text file or a binary file. The available actions include deleting and replacing portions of the file, and appending and inserting text into the file.
| Field Summary | |
static int |
APPEND
Indicate that we wish to perform a append operation. |
static int |
DELETE
Indicate that we wish to perform a delete operation. |
static int |
INSERT
Indicate that we wish to perform a insert operation. |
static int |
NONE
Indicate that no action has been set. |
static int |
OFFSET_AND_LENGTH
Indicate that we are identifying the text to modify using offset and/or length. |
static boolean |
PER_FILE
Indicate that we wish to perform the action on a per-file basis. |
static boolean |
PER_LINE
Indicate that we wish to perform the action on a per-line basis. |
static int |
REGEXP
Indicate that we are identifying the text to modify using a regular expression. |
static int |
REPLACE
Indicate that we wish to perform a replace operation. |
static java.lang.String |
SEQ_SEPARATOR
The character used to separate items in a sequence in the match expression. |
static int |
STEP_SIZE_UPPER_LIMIT
The upper limit on the step size which will be employed when reading and writing portions of files. |
| Fields inherited from class uk.org.ogsadai.activity.files.AbstractFileActivity |
mConnectionManager, mTopDir |
| Fields inherited from class uk.org.ogsadai.engine.Activity |
mContext, mExternalInputs, mExternalOutputs, mInternalInputs, mInternalOutputs |
| Constructor Summary | |
FileWritingActivity(org.w3c.dom.Element element)
Parses the perform document which is passed as the parameter. |
|
| Method Summary | |
static int |
charAt(java.io.RandomAccessFile raFile,
long pos)
Returns the byte at a particular offset within a file. |
static java.lang.String |
getFileContents(java.io.RandomAccessFile raFile)
Obtains the entire content of a file and returns it as a single string. |
protected void |
initialise()
Set up the input stream if we are expecting to receive data from a previous activity. |
static void |
overwriteString(java.io.RandomAccessFile raFile,
long offset,
java.lang.String replacementString)
Overwrite a sequence of bytes in a file with a replacement string. |
void |
processBlock()
Perform the desired action, causing the file to be permanently rewritten. |
java.lang.String |
readLine(java.io.RandomAccessFile raFile)
|
static void |
replaceWithLongerString(java.io.RandomAccessFile raFile,
long offset,
long length,
java.lang.String replacementString,
int step)
Replace a sequence of contiguous bytes in a file with a replacement string, which is strictly longer than the sequence of bytes. |
static void |
replaceWithShorterString(java.io.RandomAccessFile raFile,
long offset,
long length,
java.lang.String replacementString,
int step)
Replace a sequence of contiguous bytes in a file with a replacement string, which is strictly shorter than the sequence of bytes. |
| Methods inherited from class uk.org.ogsadai.engine.Activity |
cleanUp, connectsTo, getActivityConfiguration, getName, getObservableStatus, getProperties, getStatus, hasActivityConfiguration, hasProperties, processFirst, setCompleted, setError |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String SEQ_SEPARATOR
public static final int STEP_SIZE_UPPER_LIMIT
public static final int NONE
public static final int DELETE
public static final int REPLACE
public static final int APPEND
public static final int INSERT
public static final int OFFSET_AND_LENGTH
public static final int REGEXP
public static final boolean PER_FILE
public static final boolean PER_LINE
| Constructor Detail |
public FileWritingActivity(org.w3c.dom.Element element)
throws ActivitySystemException,
ActivityUserException
element - the perform document
ActivitySystemException - if there is a problem constructing the activity
ActivityUserException - if there was an error in the perform document| Method Detail |
protected void initialise()
throws ActivitySystemException,
ActivityUserException
initialise in class AbstractFileActivityActivityUserException - If there is a user problem intialising the activity, like
the top-level directory specified in the connection
configuration does not exist.
ActivitySystemException - If there is a problem intialising the activity, like not
using the FileSystemConnectionManager
connection manager.Activity.initialise()public void processBlock()
processBlock in class Activity
public static void overwriteString(java.io.RandomAccessFile raFile,
long offset,
java.lang.String replacementString)
throws java.io.IOException
raFile - the file to overwrite bytes inoffset - the offset of the start of the bytes to overwritereplacementString - the string to overwrite the bytes with
java.io.IOException - if there's a problem accessing the file
public static void replaceWithLongerString(java.io.RandomAccessFile raFile,
long offset,
long length,
java.lang.String replacementString,
int step)
throws java.io.IOException
This is achieved by performing the following three operations:
raFile - the file within which to replace bytesoffset - the offset of the start of the bytes to replacelength - the number of bytes to replacereplacementString - the string to replace the bytes with, which must be longer than the number of bytes to replacestep - the number of bytes we shift at a time
java.io.IOException - if there's a problem accessing the file
public static void replaceWithShorterString(java.io.RandomAccessFile raFile,
long offset,
long length,
java.lang.String replacementString,
int step)
throws java.io.IOException
This is achieved by performing the following three operations:
raFile - the file within which to replace bytesoffset - the offset of the start of the bytes to replacelength - the number of bytes to replacereplacementString - the string to replace the bytes with, which must be shorter than the number of bytes to replacestep - the number of bytes we shift at a time
java.io.IOException - if there's a problem accessing the file
public static java.lang.String getFileContents(java.io.RandomAccessFile raFile)
throws java.io.IOException,
CommonSystemException
raFile - the file to get the content of
java.io.IOException - if there's a problem accessing the file
CommonSystemException
public java.lang.String readLine(java.io.RandomAccessFile raFile)
throws java.io.IOException
java.io.IOException
public static int charAt(java.io.RandomAccessFile raFile,
long pos)
throws java.io.IOException
raFile - the filepos - the offset within the file
java.io.IOException - if there was a problem accessing the file
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||