com.jmw.tzap.filters
Class ReplaceFilter

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

public class ReplaceFilter
extends IteratingFilter

Replaces a regular expression in a buffer.


Field Summary
protected  int count
           
protected  int fileCount
           
protected  java.lang.String regex
           
protected  boolean replaceFirst
           
protected  java.lang.String replacement
           
 
Fields inherited from class com.jmw.tzap.AbstractFilter
encoding, MSG_DEBUG, MSG_ERR, MSG_INFO, MSG_VERBOSE, MSG_WARN, task
 
Constructor Summary
ReplaceFilter()
           
 
Method Summary
 java.lang.StringBuffer doFilter(java.lang.StringBuffer sb, java.lang.String fileName)
          Does the actual filtering.
 void setFirstOnly(boolean first)
          Sets the repalce first only flag.
 void setRegex(java.lang.String regexp)
          Sets the regular expression to be replaced.
 void setReplacement(java.lang.String replacement)
          Sets the replacment value.
 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, load
 
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

regex

protected java.lang.String regex

replacement

protected java.lang.String replacement

count

protected int count

fileCount

protected int fileCount

replaceFirst

protected boolean replaceFirst
Constructor Detail

ReplaceFilter

public ReplaceFilter()
Method Detail

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

setRegex

public void setRegex(java.lang.String regexp)
Sets the regular expression to be replaced.

Parameters:
regexp - the regular expression

setReplacement

public void setReplacement(java.lang.String replacement)
Sets the replacment value.

Parameters:
replacment - the string to replace the regex with

setFirstOnly

public void setFirstOnly(boolean first)
Sets the repalce first only flag.

Parameters:
first - the flag value