if (classifier == null ) {
if (simpleFilter == null) {
return getUnclassifiedReader();
}
else {
final StackTraceReader unclassified = getUnclassifiedReader();
return new StackTraceReader() {
@Override
public boolean loadNext() throws IOException {
while(unclassified.loadNext()) {
StackTraceElement[] trace = getTrace();
for(StackTraceElement e: trace) {
if (e.toString().startsWith(simpleFilter)) {
return true;
}
}
}
return false;
}
@Override
public boolean isLoaded() {
return unclassified.isLoaded();
}
@Override
public StackTraceElement[] getTrace() {
return unclassified.getTrace();
}
@Override
public long getTimestamp() {
return unclassified.getTimestamp();
}
@Override
public long getThreadId() {
return unclassified.getThreadId();
}
};
}
}
else {
if (simpleFilter != null) {
SJK.fail("Simple filter cannot be used with classification");
}
if (bucket != null && !buckets.getClasses().contains(bucket)) {
SJK.fail("Bucket [" + bucket + "] is not defined");
}
final StackTraceReader unfiltered = getUnclassifiedReader();
return new StackTraceReader() {
@Override
public boolean loadNext() throws IOException {
while(true) {
if (unfiltered.loadNext()) {
String cl = buckets.classify(unfiltered.getTrace());
if (bucket != null) {
if (!bucket.equals(cl)) {
continue;
}
}
else if (cl == null) {
continue;
}
return true;
}
else {
return false;
}
}
}
@Override
public boolean isLoaded() {
return unfiltered.isLoaded();
}
@Override
public StackTraceElement[] getTrace() {
return unfiltered.getTrace();
}
@Override
public long getTimestamp() {
return unfiltered.getTimestamp();
}
@Override
public long getThreadId() {
return unfiltered.getThreadId();
}
};
}
}