com.jmw.tzap.filters
Class ReplaceListFilter

java.lang.Object
  extended by com.jmw.tzap.AbstractFilter
      extended by com.jmw.tzap.IteratingFilter
          extended by com.jmw.tzap.filters.ReplaceListFilter

public class ReplaceListFilter
extends IteratingFilter

Replaces all regex and match pairs found in the matchfile. The match file must be structured like a properties file. For example:

                abc=123
                M(.)*=Moose
                [a-z]=Z$1
 
Any line that begins with a # will be ignored. Optionally a prefix and or suffix may be added to each regex.


Field Summary
protected  java.lang.String matchFile
           
protected  java.lang.String prefix
           
protected  java.lang.String suffix
           
 
Fields inherited from class com.jmw.tzap.AbstractFilter
encoding, MSG_DEBUG, MSG_ERR, MSG_INFO, MSG_VERBOSE, MSG_WARN, task
 
Constructor Summary
ReplaceListFilter()
           
 
Method Summary
 java.lang.StringBuffer doFilter(java.lang.StringBuffer sb, java.lang.String fileName)
          Does the actual filtering.
 void load()
          Loads the list of regex's from the specified file.
 void setMatchFile(java.lang.String matchFile)
          Sets the matchfile that contains the regex's
 void setPrefix(java.lang.String prefix)
          Sets the regex prefix that will be appended to each regex in the matchfile.
 void setSuffix(java.lang.String suffix)
          Sets the regex suffix that will be appended to each regex in the matchfile.
 void unload()
          Does any clean up after the filter has been finished.
 void validateParameters()
          Validates any parameters needed by the child filters.
 
Methods inherited from class com.jmw.tzap.IteratingFilter
execute
 
Methods inherited from class com.jmw.tzap.AbstractFilter
getName, log, log, setEncoding, setTask
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

matchFile

protected java.lang.String matchFile

prefix

protected java.lang.String prefix

suffix

protected java.lang.String suffix
Constructor Detail

ReplaceListFilter

public ReplaceListFilter()
Method Detail

load

public void load()
Loads the list of regex's from the specified file.

Overrides:
load in class IteratingFilter

unload

public void unload()
Description copied from class: AbstractFilter
Does any clean up after the filter has been finished. Note; Only called once, when all files have been filtered.

Overrides:
unload in class IteratingFilter

doFilter

public java.lang.StringBuffer doFilter(java.lang.StringBuffer sb,
                                       java.lang.String fileName)
Description copied from class: IteratingFilter
Does the actual filtering.

Specified by:
doFilter in class IteratingFilter
Parameters:
sb - the file to be filtered as a StringBuffer
fileName - the name that this file is called on disk
Returns:
the filtered file as a StringBuffer

validateParameters

public void validateParameters()
                        throws java.lang.Exception
Description copied from class: AbstractFilter
Validates any parameters needed by the child filters.

Specified by:
validateParameters in class AbstractFilter
Throws:
java.lang.Exception

setMatchFile

public void setMatchFile(java.lang.String matchFile)
Sets the matchfile that contains the regex's

Parameters:
matchfile - the name of the matchfile

setPrefix

public void setPrefix(java.lang.String prefix)
Sets the regex prefix that will be appended to each regex in the matchfile.

Parameters:
prefix - the prefix to append

setSuffix

public void setSuffix(java.lang.String suffix)
Sets the regex suffix that will be appended to each regex in the matchfile.

Parameters:
suffix - the suffix to append