public QueryCriteria convertToQueryCriteria()
throws QueryFormulationException {
switch (this.op) {
case GREATER_THAN:
return new RangeQueryCriteria(this.key, this.val, null, false);
case LESS_THAN:
return new RangeQueryCriteria(this.key, null, this.val, false);
case EQUAL_TO:
return new TermQueryCriteria(this.key, this.val);
case NOT_EQUAL_TO:
BooleanQueryCriteria notEqBQC = new BooleanQueryCriteria();
notEqBQC.setOperator(BooleanQueryCriteria.NOT);
notEqBQC.addTerm(new TermQueryCriteria(this.key, this.val));
return notEqBQC;
case GREATER_THAN_OR_EQUAL_TO:
return new RangeQueryCriteria(this.key, this.val, null, true);
case LESS_THAN_OR_EQUAL_TO:
return new RangeQueryCriteria(this.key, null, this.val, true);
}
throw new QueryFormulationException(
"Was not able to form query . . . probably an invalid operator -- "
+ this.toString());
}