*/
public SQLExpression getExpression(SQLExpression expr, List args)
{
if (args == null || args.size() == 0 || args.size() > 2)
{
throw new NucleusException(LOCALISER.msg("060003", "indexOf", "StringExpression", 0,
"StringExpression/CharacterExpression/ParameterLiteral"));
}
else
{
// {stringExpr}.indexOf(strExpr1 [,numExpr2])
SQLExpression one = ExpressionUtils.getLiteralForOne(stmt);
ArrayList funcArgs = new ArrayList();
funcArgs.add(expr);
List funcArgs2 = new ArrayList();
SQLExpression substrExpr = (SQLExpression)args.get(0);
if (!(substrExpr instanceof StringExpression) &&
!(substrExpr instanceof CharacterExpression) &&
!(substrExpr instanceof ParameterLiteral))
{
throw new NucleusException(LOCALISER.msg("060003", "indexOf", "StringExpression", 0,
"StringExpression/CharacterExpression/ParameterLiteral"));
}
funcArgs2.add(substrExpr);
List types = new ArrayList();
types.add("VARCHAR(4000)"); // max 4000 according DB2 docs
funcArgs.add(new StringExpression(stmt, getMappingForClass(String.class), "CAST", funcArgs2, types));
if (args.size() == 2)
{
SQLExpression fromExpr = (SQLExpression)args.get(1);
if (!(fromExpr instanceof NumericExpression))
{
throw new NucleusException(LOCALISER.msg("060003", "indexOf", "StringExpression", 1,
"NumericExpression"));
}
types = new ArrayList();
types.add("BIGINT");