com.jmw.tzap.filters
Class ExtractLinesFilter

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

public class ExtractLinesFilter
extends IteratingFilter

Extracts a given number of lines from a buffer and drops the rest.


Field Summary
protected  int count
           
protected  int fileCount
           
protected  int lines
           
protected  boolean replaceFirst
           
 
Fields inherited from class com.jmw.tzap.AbstractFilter
encoding, MSG_DEBUG, MSG_ERR, MSG_INFO, MSG_VERBOSE, MSG_WARN, task
 
Constructor Summary
ExtractLinesFilter()
           
 
Method Summary
 java.lang.StringBuffer doFilter(java.lang.StringBuffer sb, java.lang.String fileName)
          Extracts the lines from the buffer and returns only those extracted lines.
 void setLines(int lines)
          Sets the number of lines to extract
 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

lines

protected int lines

count

protected int count

fileCount

protected int fileCount

replaceFirst

protected boolean replaceFirst
Constructor Detail

ExtractLinesFilter

public ExtractLinesFilter()
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)
Extracts the lines from the buffer and returns only those extracted lines.

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

setLines

public void setLines(int lines)
Sets the number of lines to extract

Parameters:
lines - the string to replace the regex with