uk.org.ogsadai.client.toolkit.activity.files
Class FileReplace

java.lang.Object
  |
  +--uk.org.ogsadai.client.toolkit.activity.RequestComponent
        |
        +--uk.org.ogsadai.client.toolkit.activity.Activity
              |
              +--uk.org.ogsadai.client.toolkit.activity.files.FileWriting
                    |
                    +--uk.org.ogsadai.client.toolkit.activity.files.FileReplace

public class FileReplace
extends FileWriting

A file writing activity which replaces data matching a regular expression from a file or from each line in a file. The data can be specified by position or via a regular expression. The file resides within a file system data service resource.

The activity has one optional input - the output of another activity providing the replacement data. This can be specified using the setInput method. The activity has one output - a dummy value representing success.

If the constructor with a text parameter is not used, it is expected that the setInput method will be called in order to register that the input will be taken from another activity's output. If the constructor with a text parameter is used, any input registered via setInput is ignored.

Author:
The OGSA-DAI Project Team

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
          Copyright statement
 
Fields inherited from class uk.org.ogsadai.client.toolkit.activity.files.FileWriting
APPEND, DELETE, END, INSERT, mAction, mFilename, mLength, mMatch, mOffset, mPerLine, mRegexp, mText, NONE_SPECIFIED, PER_FILE, PER_LINE, REPLACE, START, TO_END
 
Fields inherited from class uk.org.ogsadai.client.toolkit.activity.Activity
 
Fields inherited from class uk.org.ogsadai.client.toolkit.activity.RequestComponent
 
Constructor Summary
FileReplace(java.lang.String filename, int offset, int length, boolean perLine)
          Replace a particular range of bytes from an entire file or from each line of a file.
FileReplace(java.lang.String filename, int offset, int length, boolean perLine, java.lang.String text)
          Replace a particular range of bytes from an entire file or from each line of a file.
FileReplace(java.lang.String filename, java.lang.String regexp, java.lang.String match, boolean perLine)
          Replaces particular instances of a match of a regular expression in an entire file or within each line of a file with particular text.
FileReplace(java.lang.String filename, java.lang.String regexp, java.lang.String match, boolean perLine, java.lang.String text)
          Replaces particular instances of a match of a regular expression in an entire file or within each line of a file with particular text.
 
Methods inherited from class uk.org.ogsadai.client.toolkit.activity.files.FileWriting
actionToString, generateXML, getFilename, getLength, getMatch, getOffset, getRegexp, getText, isPerLine, lengthToString, offsetToString, setFilename, setInput, setLength, setMatch, setOffset, setPerLine, setRegexp, setText, validateParams
 
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
Constructor Detail

FileReplace

public FileReplace(java.lang.String filename,
                   java.lang.String regexp,
                   java.lang.String match,
                   boolean perLine,
                   java.lang.String text)
Replaces particular instances of a match of a regular expression in an entire file or within each line of a file with particular text.

The instances can be selected using a match expression, which is a comma-separated list of values. The values may be any of:
ValueStringRepresents
Single, positive integers x The integer x
Finite ranges of positive integers x-y The interval [x, y], where x < y
Infinite ranges of positive integers x- The interval [x, infinity)
Strictly increasing infinite sequences of positive integers x1:x2:x3:... The infinite sequence (x1, x2, x3, ...), where x1 < x2 and x2 < x3

Parameters:
filename - Relative path to the the file to replace text in.
regexp - Regular expression to match text with.
match - Expression denoting which instances of when the regular expression is matched to deal with as specified above.
perLine - true treats the match expression on a per-line basis, false treats the match expression on a per-file basis
text - Replacement text
Throws:
java.lang.IllegalArgumentException - If filename or text is null

FileReplace

public FileReplace(java.lang.String filename,
                   int offset,
                   int length,
                   boolean perLine,
                   java.lang.String text)
Replace a particular range of bytes from an entire file or from each line of a file.

Parameters:
filename - Relative path to the the file to replace text in.
offset - Non-negative offset of start of the range of bytes, or FileWriting.BOF, or FileWriting.EOF
length - Non-negative length of the range of bytes, or FileWriting.TO_EOF
perLine - true treats the match expression on a per-line basis, false treats the match expression on a per-file basis
text - Replacement text
Throws:
java.lang.IllegalArgumentException - If filename or text is null or offset and length are not as specified above.

FileReplace

public FileReplace(java.lang.String filename,
                   java.lang.String regexp,
                   java.lang.String match,
                   boolean perLine)
Replaces particular instances of a match of a regular expression in an entire file or within each line of a file with particular text.

The setInput method should be called to specify the activity that will provide the data.

The instances can be selected using a match expression, which is a comma-separated list of values. The values may be any of:
ValueStringRepresents
Single, positive integers x The integer x
Finite ranges of positive integers x-y The interval [x, y], where x < y
Infinite ranges of positive integers x- The interval [x, infinity)
Strictly increasing infinite sequences of positive integers x1:x2:x3:... The infinite sequence (x1, x2, x3, ...), where x1 < x2 and x2 < x3

Parameters:
filename - Relative path to the the file to replace text in.
regexp - Regular expression to match text with.
match - Expression denoting which instances of when the regular expression is matched to deal with as specified above.
perLine - true treats the match expression on a per-line basis, false treats the match expression on a per-file basis
Throws:
java.lang.IllegalArgumentException - If filename is null

FileReplace

public FileReplace(java.lang.String filename,
                   int offset,
                   int length,
                   boolean perLine)
Replace a particular range of bytes from an entire file or from each line of a file.

The setInput method should be called to specify the activity that will provide the data.

Parameters:
filename - Relative path to the the file to replace text in.
offset - Non-negative offset of start of the range of bytes, or FileWriting.BOF, or FileWriting.EOF
length - Non-negative length of the range of bytes, or FileWriting.TO_EOF
perLine - true treats the match expression on a per-line basis, false treats the match expression on a per-file basis
Throws:
java.lang.IllegalArgumentException - If filename is null or offset and length are not as specified above.