Package org.datanucleus.store.rdbms.sql.expression

Examples of org.datanucleus.store.rdbms.sql.expression.StringExpression


    public SQLExpression getExpression(SQLExpression expr, List args)
    {
        if (expr == null)
        {
            // We have something like "function({expr})"
            return new StringExpression(stmt, getMappingForClass(String.class), getFunctionName(), args);
        }
        else if (expr instanceof StringExpression)
        {
            // We have {stringExpr}.method(...)
            // TODO Cater for input args
            ArrayList functionArgs = new ArrayList();
            functionArgs.add(expr);
            return new StringExpression(stmt, getMappingForClass(String.class), getFunctionName(), functionArgs);
        }
        else
        {
            throw new NucleusException(LOCALISER.msg("060002", getFunctionName(), expr));
        }
View Full Code Here


            {
                SQLExpression numExpr = (SQLExpression)args.get(1);
                funcArgs.add(substrExpr);
                funcArgs.add(expr);
                return new BooleanExpression(
                    new StringExpression(stmt, getMappingForClass(int.class), "LOCATE", funcArgs), Expression.OP_EQ, one.add(numExpr));
            }
            else
            {
                funcArgs.add(substrExpr);
                funcArgs.add(expr);
                return new BooleanExpression(
                    new StringExpression(stmt, getMappingForClass(int.class), "LOCATE", funcArgs), Expression.OP_EQ, one);
            }
        }
    }
View Full Code Here

        ArrayList funcArgs = new ArrayList();
        funcArgs.add(expr);
        funcArgs.add(dd);
        ArrayList funcArgs2 = new ArrayList();
        funcArgs2.add(new StringExpression(stmt, mapping, "TO_CHAR", funcArgs));
        return new NumericExpression(stmt, getMappingForClass(int.class), "TO_NUMBER", funcArgs2);
    }
View Full Code Here

        ArrayList funcArgs = new ArrayList();
        funcArgs.add(expr);
        funcArgs.add(hh);
        ArrayList funcArgs2 = new ArrayList();
        funcArgs2.add(new StringExpression(stmt, mapping, "TO_CHAR", funcArgs));
        return new NumericExpression(stmt, getMappingForClass(int.class), "TO_NUMBER", funcArgs2);
    }
View Full Code Here

        ArrayList funcArgs = new ArrayList();
        funcArgs.add(expr);
        funcArgs.add(yyyy);
        ArrayList funcArgs2 = new ArrayList();
        funcArgs2.add(new StringExpression(stmt, mapping, "TO_CHAR", funcArgs));
        return new NumericExpression(stmt, getMappingForClass(int.class), "TO_NUMBER", funcArgs2);
    }
View Full Code Here

            {
                NumericExpression numExpr = (NumericExpression) args.get(1);
                funcArgs.add(substrExpr);
                funcArgs.add(expr);
                return new BooleanExpression(
                    new StringExpression(stmt, getMappingForClass(int.class), "CHARINDEX", funcArgs), Expression.OP_EQ,
                        one.add(numExpr));
            }
            else
            {
                funcArgs.add(substrExpr);
                funcArgs.add(expr);
                return new BooleanExpression(
                    new StringExpression(stmt, getMappingForClass(int.class), "CHARINDEX", funcArgs), Expression.OP_EQ, one);
            }
        }
    }
View Full Code Here

            List<SQLExpression> newArgs = new ArrayList<SQLExpression>(3);
            newArgs.add(expr);
            newArgs.add(strExpr1);
            newArgs.add(strExpr2);
            JavaTypeMapping mapping = exprFactory.getMappingForType(String.class, false);
            return new StringExpression(stmt, mapping, "translate", newArgs);
        }
    }
View Full Code Here

            {
                trimArgs.add(expr);
            }
            else
            {
                StringExpression argExpr = new StringExpression(stmt, expr.getJavaTypeMapping(), "NULL", null);
                SQLText sql = argExpr.toSQLText();
                sql.clearStatement();
                sql.append(getTrimSpecKeyword() + " ");
                sql.append(trimCharExpr);
                sql.append(" FROM ");
                sql.append(expr);
                trimArgs.add(argExpr);
            }

            StringExpression trimExpr = new StringExpression(stmt, expr.getJavaTypeMapping(), "TRIM", trimArgs);
            return trimExpr;
        }
    }
View Full Code Here

            SQLExpression one = ExpressionUtils.getLiteralForOne(stmt);

            ArrayList funcArgs = new ArrayList();
            funcArgs.add(expr);
            funcArgs.add(startExpr.add(one));
            return new StringExpression(stmt, getMappingForClass(String.class), "SUBSTR", 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), "SUBSTR", funcArgs);
        }
    }
View Full Code Here

        {
            throw new NucleusException(LOCALISER.msg("060003", "endsWith", "StringExpression", 0,
                "StringExpression/CharacterExpression/ParameterLiteral"));
        }

        StringExpression strExpr1 = (StringExpression)expr;
        StringExpression strExpr2 = (StringExpression)args.get(0);
        return strExpr1.eq(strExpr2);
    }
View Full Code Here

TOP

Related Classes of org.datanucleus.store.rdbms.sql.expression.StringExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.