if (node instanceof ParametricRangeQueryNode) {
QueryConfigHandler config = getQueryConfigHandler();
if (config != null) {
ParametricRangeQueryNode parametricRangeNode = (ParametricRangeQueryNode) node;
FieldConfig fieldConfig = config.getFieldConfig(StringUtils
.toString(parametricRangeNode.getField()));
if (fieldConfig != null) {
NumericConfig numericConfig = fieldConfig
.get(ConfigurationKeys.NUMERIC_CONFIG);
if (numericConfig != null) {
ParametricQueryNode lower = parametricRangeNode.getLowerBound();
ParametricQueryNode upper = parametricRangeNode.getUpperBound();
NumberFormat numberFormat = numericConfig.getNumberFormat();
Number lowerNumber, upperNumber;
try {
lowerNumber = numberFormat.parse(lower.getTextAsString());
} catch (ParseException e) {
throw new QueryNodeParseException(new MessageImpl(
QueryParserMessages.COULD_NOT_PARSE_NUMBER, lower
.getTextAsString(), numberFormat.getClass()
.getCanonicalName()), e);
}
try {
upperNumber = numberFormat.parse(upper.getTextAsString());
} catch (ParseException e) {
throw new QueryNodeParseException(new MessageImpl(
QueryParserMessages.COULD_NOT_PARSE_NUMBER, upper
.getTextAsString(), numberFormat.getClass()
.getCanonicalName()), e);
}
switch (numericConfig.getType()) {
case LONG:
upperNumber = upperNumber.longValue();
lowerNumber = lowerNumber.longValue();
break;
case INT:
upperNumber = upperNumber.intValue();
lowerNumber = lowerNumber.intValue();
break;
case DOUBLE:
upperNumber = upperNumber.doubleValue();
lowerNumber = lowerNumber.doubleValue();
break;
case FLOAT:
upperNumber = upperNumber.floatValue();
lowerNumber = lowerNumber.floatValue();
}
NumericQueryNode lowerNode = new NumericQueryNode(
parametricRangeNode.getField(), lowerNumber, numberFormat);
NumericQueryNode upperNode = new NumericQueryNode(
parametricRangeNode.getField(), upperNumber, numberFormat);
boolean upperInclusive = upper.getOperator() == CompareOperator.LE;
boolean lowerInclusive = lower.getOperator() == CompareOperator.GE;
return new NumericRangeQueryNode(lowerNode, upperNode,