StatusCodeFilter.java from Tea Stats at Krugle
Show StatusCodeFilter.java syntax highlighted
/*
* This file is distributed under the GPL v2 as part of teastats site statistics package
* http://teastats.sourceforge.net
*/
package net.time4tea.webstats.filter.http;
import net.time4tea.webstats.record.Page;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
/**
* Originally richja Feb 11, 2006
*/
public class StatusCodeFilter extends BaseMatcher<Page> {
private long min = 0;
private long max = 0;
public StatusCodeFilter(long code) {
this.min = code;
this.max = code;
}
public StatusCodeFilter(long mincode, long maxcode) {
min = mincode;
max = maxcode;
}
private boolean matches(Page page) {
long status = page.getStatusCode();
if (status >= min && status <= max) {
return true;
}
return false;
}
public boolean matches(Object item) {
return item instanceof Page && matches((Page)item);
}
public void describeTo(Description description) {
throw new UnsupportedOperationException();
}
}
See more files for this project here