com.jmw.tzap.filters
Class ExtractLinesFilter
java.lang.Object
com.jmw.tzap.AbstractFilter
com.jmw.tzap.IteratingFilter
com.jmw.tzap.filters.ExtractLinesFilter
public class ExtractLinesFilter
- extends IteratingFilter
Extracts a given number of lines from a buffer and drops the rest.
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
lines
protected int lines
count
protected int count
fileCount
protected int fileCount
replaceFirst
protected boolean replaceFirst
ExtractLinesFilter
public ExtractLinesFilter()
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 StringBufferfileName
- 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