SQLExpression one = ExpressionUtils.getLiteralForOne(stmt);
ArrayList funcArgs = new ArrayList();
funcArgs.add(expr);
funcArgs.add(startExpr.add(one));
return new StringExpression(stmt, getMappingForClass(String.class), "SUBSTRING", funcArgs);
}
else
{
// {stringExpr}.substring(numExpr1, numExpr2)
SQLExpression startExpr = (SQLExpression)args.get(0);
if (!(startExpr instanceof NumericExpression))
{
throw new NucleusException(LOCALISER.msg("060003", "substring", "StringExpression", 0,
"NumericExpression"));
}
SQLExpression endExpr = (SQLExpression)args.get(1);
if (!(endExpr instanceof NumericExpression))
{
throw new NucleusException(LOCALISER.msg("060003", "substring", "StringExpression", 1,
"NumericExpression"));
}
SQLExpression one = ExpressionUtils.getLiteralForOne(stmt);
ArrayList funcArgs = new ArrayList();
funcArgs.add(expr);
funcArgs.add(startExpr.add(one));
funcArgs.add(endExpr.sub(startExpr));
return new StringExpression(stmt, getMappingForClass(String.class), "SUBSTRING", funcArgs);
}
}