public boolean hasNext() {
try {
this.nextLocation = reader.getNextMessage(currentLocation);
Message next = nextLocation != null ? nextLocation.getMessage()
: null;
if (expression == null) {
return next != null;
} else {
while (next != null) {
MessageEvaluationContext context = new MessageEvaluationContext();
context.setMessageReference((MessageReference) next);
if (expression.matches(context)) {
return true;
}
this.nextLocation = reader.getNextMessage(currentLocation);
next = nextLocation != null ? nextLocation.getMessage()
: null;
}
valid=false;
return false;
}
} catch (Exception e) {
throw new RuntimeException(
"Failed to get next message from reader ", e);
}
}
|