float cost = childCost;
try{
float maxValue = 0;
float minValue = 0;
Constant value = (Constant)compCrit.getRightExpression();
float compareValue = 0;
// Case 6257 - handling added for time and date. If the max/min values are not
// in the expected format, NumberFormatException is thrown and reverts to default costing.
if(dataType.equals(DataTypeManager.DefaultDataClasses.TIMESTAMP)) {
compareValue = ((Timestamp)value.getValue()).getTime();
maxValue = Timestamp.valueOf(max).getTime();
minValue = Timestamp.valueOf(min).getTime();
} else if(dataType.equals(DataTypeManager.DefaultDataClasses.TIME)) {
compareValue = ((Time)value.getValue()).getTime();
maxValue = Time.valueOf(max).getTime();
minValue = Time.valueOf(min).getTime();
// (For date, our costing sets the max and min values using timestamp format)
} else if(dataType.equals(DataTypeManager.DefaultDataClasses.DATE)) {
compareValue = ((Date)value.getValue()).getTime();
maxValue = Timestamp.valueOf(max).getTime();
minValue = Timestamp.valueOf(min).getTime();
} else {
if(!Number.class.isAssignableFrom(dataType)) {
if (unknownChildCost) {
return UNKNOWN_VALUE;
}
return childCost/3;
}
compareValue = ((Number)value.getValue()).floatValue();
maxValue = Integer.parseInt(max);
minValue = Integer.parseInt(min);
}
float range = Math.max(maxValue - minValue, 1);