|
Apache JMeter | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.jmeter.protocol.http.util.accesslog.LogFilter
public class LogFilter
Description:
LogFilter is a basic implementation of Filter interface. This implementation
will keep a record of the filtered strings to avoid repeating the process
unnecessarily.
The current implementation supports replacing the file extension. The reason for supporting this is from first hand experience porting an existing website to Tomcat + JSP. Later on we may want to provide the ability to replace the whole filename. If the need materializes, we can add it later.
Example of how to use it is provided in the main method. An example is provided below.
testf = new LogFilter(); String[] incl = { "hello.html", "index.html", "/index.jsp" }; String[] thefiles = { "/test/hello.jsp", "/test/one/hello.html", "hello.jsp", "hello.htm", "/test/open.jsp", "/test/open.html", "/index.jsp", "/index.jhtml", "newindex.jsp", "oldindex.jsp", "oldindex1.jsp", "oldindex2.jsp", "oldindex3.jsp", "oldindex4.jsp", "oldindex5.jsp", "oldindex6.jsp", "/test/index.htm" }; testf.excludeFiles(incl); System.out.println(" ------------ exclude test -------------"); for (int idx = 0; idx < thefiles.length; idx++) { boolean fl = testf.isFiltered(thefiles[idx]); String line = testf.filter(thefiles[idx]); if (line != null) { System.out.println("the file: " + line); } }As a general note. Both isFiltered and filter() have to be called. Calling either one will not produce the desired result. isFiltered(string) will tell you if a string should be filtered. The second step is to filter the string, which will return null if it is filtered and replace any part of the string that should be replaced.
Field Summary | |
---|---|
protected boolean |
CHANGEEXT
protected members used by class to filter * |
protected String[] |
EXCFILE
|
protected ArrayList<org.apache.oro.text.regex.Pattern> |
EXCPATTERNS
|
protected String[] |
EXCPTRN
|
protected boolean |
FILEFILTER
|
protected String[] |
INCFILE
|
protected ArrayList<org.apache.oro.text.regex.Pattern> |
INCPATTERNS
|
protected String[] |
INCPTRN
|
protected String |
NEWEXT
|
protected String |
NEWFILE
|
protected String |
OLDEXT
|
protected boolean |
PTRNFILTER
|
protected boolean |
USEFILE
|
Constructor Summary | |
---|---|
LogFilter()
The default constructor is empty |
Method Summary | |
---|---|
org.apache.oro.text.regex.Pattern |
createPattern(String pattern)
create a new pattern object from the string. |
boolean |
excFile(String text)
Method implements the logic for filtering file name exclusion. |
void |
excludeFiles(String[] filenames)
Give the filter a list of files to exclude |
void |
excludePattern(String[] regexp)
Give the filter a set of regular expressions to filter with for exclusion. |
protected boolean |
excPattern(String text)
The method assumes by default the text is not excluded. |
String |
filter(String text)
The current implementation checks the boolean if the text should be used or not. isFilter( string) has to be called first. |
protected boolean |
filterFile(String file)
Filter the file. |
protected boolean |
filterPattern(String text)
The current implemenation assumes the user has checked the regular expressions so that they don't cancel each other. |
boolean |
incFile(String text)
Method implements the logic for filtering file name inclusion. |
void |
includeFiles(String[] filenames)
Give the filter a list of files to include |
void |
includePattern(String[] regexp)
Give the filter a set of regular expressions to filter with for inclusion. |
protected boolean |
incPattern(String text)
By default, the method assumes the entry is not included, unless it matches. |
boolean |
isFiltered(String path,
TestElement el)
In the case of log filtering the important thing is whether the log entry should be used. |
boolean |
replaceExtension(String text)
Method uses indexOf to replace the old extension with the new extesion. |
void |
reset()
Tell the filter when the parsing has reached the end of the log file and is about to begin again. |
void |
setReplaceExtension(String oldext,
String newext)
The method will replace the file extension with the new one. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected boolean CHANGEEXT
protected String OLDEXT
protected String NEWEXT
protected String[] INCFILE
protected String[] EXCFILE
protected boolean FILEFILTER
protected boolean USEFILE
protected String[] INCPTRN
protected String[] EXCPTRN
protected boolean PTRNFILTER
protected ArrayList<org.apache.oro.text.regex.Pattern> EXCPATTERNS
protected ArrayList<org.apache.oro.text.regex.Pattern> INCPATTERNS
protected String NEWFILE
Constructor Detail |
---|
public LogFilter()
Method Detail |
---|
public void setReplaceExtension(String oldext, String newext)
setReplaceExtension
in interface Filter
Filter.setReplaceExtension(java.lang.String,
java.lang.String)
public void includeFiles(String[] filenames)
includeFiles
in interface Filter
filenames
- Filter.includeFiles(java.lang.String[])
public void excludeFiles(String[] filenames)
excludeFiles
in interface Filter
filenames
- Filter.excludeFiles(java.lang.String[])
public void includePattern(String[] regexp)
includePattern
in interface Filter
regexp
- Filter.includePattern(String[])
public void excludePattern(String[] regexp)
excludePattern
in interface Filter
regexp
- Filter.excludePattern(String[])
public boolean isFiltered(String path, TestElement el)
isFiltered
in interface Filter
path
-
Filter.isFiltered(String, TestElement)
protected boolean filterFile(String file)
file
-
public boolean incFile(String text)
text
-
public boolean excFile(String text)
text
-
protected boolean filterPattern(String text)
text
-
protected boolean incPattern(String text)
text
-
protected boolean excPattern(String text)
text
-
public boolean replaceExtension(String text)
text
-
public String filter(String text)
filter
in interface Filter
Filter.filter(java.lang.String)
public org.apache.oro.text.regex.Pattern createPattern(String pattern)
pattern
-
public void reset()
reset
in interface Filter
|
Apache JMeter | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |