Search in sources :

Example 31 with InvokeExpression

use of org.datanucleus.query.expression.InvokeExpression in project datanucleus-api-jdo by datanucleus.

the class StringExpressionImpl method matches.

public BooleanExpression matches(String str) {
    List<org.datanucleus.query.expression.Expression> args = new ArrayList();
    args.add(new Literal(str));
    org.datanucleus.query.expression.Expression invokeExpr = new InvokeExpression(queryExpr, "matches", args);
    return new BooleanExpressionImpl(invokeExpr);
}
Also used : InvokeExpression(org.datanucleus.query.expression.InvokeExpression) DyadicExpression(org.datanucleus.query.expression.DyadicExpression) NumericExpression(javax.jdo.query.NumericExpression) CharacterExpression(javax.jdo.query.CharacterExpression) InvokeExpression(org.datanucleus.query.expression.InvokeExpression) StringExpression(javax.jdo.query.StringExpression) PersistableExpression(javax.jdo.query.PersistableExpression) BooleanExpression(javax.jdo.query.BooleanExpression) Expression(javax.jdo.query.Expression) Literal(org.datanucleus.query.expression.Literal) ArrayList(java.util.ArrayList)

Example 32 with InvokeExpression

use of org.datanucleus.query.expression.InvokeExpression in project datanucleus-api-jdo by datanucleus.

the class StringExpressionImpl method endsWith.

/* (non-Javadoc)
     * @see org.datanucleus.query.typesafe.StringExpression#endsWith(java.lang.String)
     */
public BooleanExpression endsWith(String str) {
    List<org.datanucleus.query.expression.Expression> args = new ArrayList();
    args.add(new Literal(str));
    org.datanucleus.query.expression.Expression invokeExpr = new InvokeExpression(queryExpr, "endsWith", args);
    return new BooleanExpressionImpl(invokeExpr);
}
Also used : InvokeExpression(org.datanucleus.query.expression.InvokeExpression) DyadicExpression(org.datanucleus.query.expression.DyadicExpression) NumericExpression(javax.jdo.query.NumericExpression) CharacterExpression(javax.jdo.query.CharacterExpression) InvokeExpression(org.datanucleus.query.expression.InvokeExpression) StringExpression(javax.jdo.query.StringExpression) PersistableExpression(javax.jdo.query.PersistableExpression) BooleanExpression(javax.jdo.query.BooleanExpression) Expression(javax.jdo.query.Expression) Literal(org.datanucleus.query.expression.Literal) ArrayList(java.util.ArrayList)

Example 33 with InvokeExpression

use of org.datanucleus.query.expression.InvokeExpression in project datanucleus-api-jdo by datanucleus.

the class StringExpressionImpl method charAt.

/* (non-Javadoc)
     * @see org.datanucleus.query.typesafe.StringExpression#charAt(int)
     */
public CharacterExpression charAt(int pos) {
    List<org.datanucleus.query.expression.Expression> args = new ArrayList();
    args.add(new Literal(pos));
    org.datanucleus.query.expression.Expression invokeExpr = new InvokeExpression(queryExpr, "charAt", args);
    return new CharacterExpressionImpl(invokeExpr);
}
Also used : InvokeExpression(org.datanucleus.query.expression.InvokeExpression) DyadicExpression(org.datanucleus.query.expression.DyadicExpression) NumericExpression(javax.jdo.query.NumericExpression) CharacterExpression(javax.jdo.query.CharacterExpression) InvokeExpression(org.datanucleus.query.expression.InvokeExpression) StringExpression(javax.jdo.query.StringExpression) PersistableExpression(javax.jdo.query.PersistableExpression) BooleanExpression(javax.jdo.query.BooleanExpression) Expression(javax.jdo.query.Expression) Literal(org.datanucleus.query.expression.Literal) ArrayList(java.util.ArrayList)

Example 34 with InvokeExpression

use of org.datanucleus.query.expression.InvokeExpression in project datanucleus-api-jdo by datanucleus.

the class JDOHelperGetObjectIdFunction method evaluate.

/* (non-Javadoc)
     * @see org.datanucleus.query.evaluator.memory.InvocationEvaluator#evaluate(org.datanucleus.query.expression.InvokeExpression, org.datanucleus.query.evaluator.memory.InMemoryExpressionEvaluator)
     */
public Object evaluate(InvokeExpression expr, Object invokedValue, InMemoryExpressionEvaluator eval) {
    Expression argExpr = expr.getArguments().get(0);
    if (argExpr instanceof PrimaryExpression) {
        PrimaryExpression primExpr = (PrimaryExpression) argExpr;
        Object value = eval.getValueForPrimaryExpression(primExpr);
        return JDOHelper.getObjectId(value);
    } else if (argExpr instanceof ParameterExpression) {
        ParameterExpression paramExpr = (ParameterExpression) argExpr;
        Object value = QueryUtils.getValueForParameterExpression(eval.getParameterValues(), paramExpr);
        return JDOHelper.getObjectId(value);
    } else {
        throw new NucleusException("Dont currently support JDOHelper.getObjectId with arg of type " + argExpr.getClass().getName());
    }
}
Also used : PrimaryExpression(org.datanucleus.query.expression.PrimaryExpression) PrimaryExpression(org.datanucleus.query.expression.PrimaryExpression) ParameterExpression(org.datanucleus.query.expression.ParameterExpression) Expression(org.datanucleus.query.expression.Expression) InvokeExpression(org.datanucleus.query.expression.InvokeExpression) ParameterExpression(org.datanucleus.query.expression.ParameterExpression) NucleusException(org.datanucleus.exceptions.NucleusException)

Example 35 with InvokeExpression

use of org.datanucleus.query.expression.InvokeExpression in project datanucleus-api-jdo by datanucleus.

the class JDOHelperGetVersionFunction method evaluate.

/* (non-Javadoc)
     * @see org.datanucleus.query.evaluator.memory.InvocationEvaluator#evaluate(org.datanucleus.query.expression.InvokeExpression, org.datanucleus.query.evaluator.memory.InMemoryExpressionEvaluator)
     */
public Object evaluate(InvokeExpression expr, Object invokedValue, InMemoryExpressionEvaluator eval) {
    Expression argExpr = expr.getArguments().get(0);
    if (argExpr instanceof PrimaryExpression) {
        PrimaryExpression primExpr = (PrimaryExpression) argExpr;
        Object value = eval.getValueForPrimaryExpression(primExpr);
        return JDOHelper.getVersion(value);
    } else if (argExpr instanceof ParameterExpression) {
        ParameterExpression paramExpr = (ParameterExpression) argExpr;
        Object value = QueryUtils.getValueForParameterExpression(eval.getParameterValues(), paramExpr);
        return JDOHelper.getVersion(value);
    } else {
        throw new NucleusException("Dont currently support JDOHelper.getVersion with arg of type " + argExpr.getClass().getName());
    }
}
Also used : PrimaryExpression(org.datanucleus.query.expression.PrimaryExpression) PrimaryExpression(org.datanucleus.query.expression.PrimaryExpression) ParameterExpression(org.datanucleus.query.expression.ParameterExpression) Expression(org.datanucleus.query.expression.Expression) InvokeExpression(org.datanucleus.query.expression.InvokeExpression) ParameterExpression(org.datanucleus.query.expression.ParameterExpression) NucleusException(org.datanucleus.exceptions.NucleusException)

Aggregations

InvokeExpression (org.datanucleus.query.expression.InvokeExpression)65 Literal (org.datanucleus.query.expression.Literal)42 DyadicExpression (org.datanucleus.query.expression.DyadicExpression)40 Expression (org.datanucleus.query.expression.Expression)39 PrimaryExpression (org.datanucleus.query.expression.PrimaryExpression)38 ParameterExpression (org.datanucleus.query.expression.ParameterExpression)37 NucleusException (org.datanucleus.exceptions.NucleusException)32 ArrayList (java.util.ArrayList)25 VariableExpression (org.datanucleus.query.expression.VariableExpression)21 BooleanExpression (javax.jdo.query.BooleanExpression)17 NumericExpression (javax.jdo.query.NumericExpression)17 PersistableExpression (javax.jdo.query.PersistableExpression)17 Expression (javax.jdo.query.Expression)15 NucleusUserException (org.datanucleus.exceptions.NucleusUserException)13 OrderExpression (org.datanucleus.query.expression.OrderExpression)12 List (java.util.List)10 CharacterExpression (javax.jdo.query.CharacterExpression)10 StringExpression (javax.jdo.query.StringExpression)10 LocalDateTime (java.time.LocalDateTime)7 Calendar (java.util.Calendar)7