switch (type)
{
case TypeConstants.dateTime:
// System.out.println("Expression factory creating new date time: "+
// val.toString());
returnExpr = new DateTimeConstant(val);
break;
case TypeConstants.charType:
char[] cArr = val.toCharArray();
returnExpr = new CharConstant(cArr[0]);
break;
case TypeConstants.doubleType:
returnExpr = new DoubleConstant(Double.valueOf(val).doubleValue());
break;
case TypeConstants.floatType:
returnExpr = new FloatConstant(Float.valueOf(val).floatValue());
break;
case TypeConstants.intType:
returnExpr = new IntegerConstant(Integer.valueOf(val).intValue());
break;
case TypeConstants.shortType:
returnExpr = new ShortConstant(Short.valueOf(val).shortValue());
break;
case TypeConstants.longType:
if (val.endsWith("L") || val.endsWith("l"))
{
val = val.substring(0, val.length() - 2);
}
returnExpr = new LongConstant(Long.valueOf(val).longValue());
break;
case TypeConstants.stringType:
String dateStr = (String) val;
if (DateTime.isDateTimeString(dateStr))
{
// System.out.println("string is a date string
// createJavaDateTime "+val);
int size = dateStr.length();
returnExpr = new DateTimeConstant(dateStr
.substring(1, size - 1));
}
else
{
returnExpr = new StringConstant(val);