Package org.datanucleus.query.expression

Examples of org.datanucleus.query.expression.Literal


     * @see javax.persistence.criteria.Expression#isNotNull()
     */
    public Predicate isNotNull()
    {
        PredicateImpl pred = new PredicateImpl();
        Literal lit = new Literal(null);
        org.datanucleus.query.expression.Expression queryExpr =
            new DyadicExpression(getQueryExpression(),
                org.datanucleus.query.expression.Expression.OP_NOTEQ,
                lit);
        pred.queryExpr = queryExpr;
View Full Code Here


     * @see javax.persistence.criteria.Expression#isNull()
     */
    public Predicate isNull()
    {
        PredicateImpl pred = new PredicateImpl();
        Literal lit = new Literal(null);
        org.datanucleus.query.expression.Expression queryExpr =
            new DyadicExpression(this.getQueryExpression(),
                org.datanucleus.query.expression.Expression.OP_EQ,
                lit);
        pred.queryExpr = queryExpr;
View Full Code Here

        }
      }

      if (param instanceof Literal) {
        String matchesExpr = getPrefixFromMatchesExpression(((Literal) param).getLiteral());
        addPrefix(leftExpr, new Literal(matchesExpr), matchesExpr, qd);
        return;
      } else if (param instanceof ParameterExpression) {
        ParameterExpression parameterExpression = (ParameterExpression) param;
        Object parameterValue = getParameterValue(qd.parameters, parameterExpression);
        String matchesExpr = getPrefixFromMatchesExpression(parameterValue);
        addPrefix(leftExpr, new Literal(matchesExpr), matchesExpr, qd);
        return;
      }
    }

    // We don't know what this is.
View Full Code Here

    byte[] bytes = val.getBytes();
    for (int i = bytes.length - 1; i >= 0; i--) {
      byte[] endKey = new byte[i + 1];
      System.arraycopy(bytes, 0, endKey, 0, i + 1);
      if (++endKey[i] != 0) {
        return new Literal(new String(endKey));
      }
    }
    return null;
  }
View Full Code Here

  private void handleMatchesOperation(InvokeExpression invocation, Expression expr,
                                      QueryData qd) {
    Expression param = (Expression) invocation.getArguments().get(0);
    if (expr.getLeft() instanceof PrimaryExpression && param instanceof Literal) {
      String matchesExpr = getPrefixFromMatchesExpression(((Literal) param).getLiteral());
      addPrefix((PrimaryExpression) expr.getLeft(), new Literal(matchesExpr), matchesExpr, qd);
    } else if (expr.getLeft() instanceof PrimaryExpression &&
               param instanceof ParameterExpression) {
      ParameterExpression parameterExpression = (ParameterExpression) param;
      Object parameterValue = getParameterValue(qd, parameterExpression);
      String matchesExpr = getPrefixFromMatchesExpression(parameterValue);
      addPrefix((PrimaryExpression) expr.getLeft(), new Literal(matchesExpr), matchesExpr, qd);
    } else {
      // We don't know what this is.
      throw newUnsupportedQueryMethodException(invocation);
    }
  }
View Full Code Here

    byte[] bytes = val.getBytes();
    for (int i = bytes.length - 1; i >= 0; i--) {
      byte[] endKey = new byte[i + 1];
      System.arraycopy(bytes, 0, endKey, 0, i + 1);
      if (++endKey[i] != 0) {
        return new Literal(new String(endKey));
      }
    }
    return null;
  }
View Full Code Here

  private void handleMatchesOperation(InvokeExpression invocation, Expression expr,
                                      QueryData qd) {
    Expression param = (Expression) invocation.getArguments().get(0);
    if (expr.getLeft() instanceof PrimaryExpression && param instanceof Literal) {
      String matchesExpr = getPrefixFromMatchesExpression(((Literal) param).getLiteral());
      addPrefix((PrimaryExpression) expr.getLeft(), new Literal(matchesExpr), matchesExpr, qd);
    } else if (expr.getLeft() instanceof PrimaryExpression &&
               param instanceof ParameterExpression) {
      ParameterExpression parameterExpression = (ParameterExpression) param;
      Object parameterValue = getParameterValue(qd, parameterExpression);
      String matchesExpr = getPrefixFromMatchesExpression(parameterValue);
      addPrefix((PrimaryExpression) expr.getLeft(), new Literal(matchesExpr), matchesExpr, qd);
    } else {
      // We don't know what this is.
      throw newUnsupportedQueryMethodException(invocation);
    }
  }
View Full Code Here

    byte[] bytes = val.getBytes();
    for (int i = bytes.length - 1; i >= 0; i--) {
      byte[] endKey = new byte[i + 1];
      System.arraycopy(bytes, 0, endKey, 0, i + 1);
      if (++endKey[i] != 0) {
        return new Literal(new String(endKey));
      }
    }
    return null;
  }
View Full Code Here

            Object obj = getValueForParameterExpression(parameters, paramExpr);
            paramValue = getStringValue(obj);
        }
        else if (expr instanceof Literal)
        {
            Literal literal = (Literal) expr;
            paramValue = getStringValue(literal.getLiteral());
        }
        else
        {
            throw new NucleusException(
                    "getStringValueForExpression(expr) where expr is instanceof " + expr.getClass().getName() + " not supported");
View Full Code Here

        {
            param = expr.getArguments().get(1);
            int arg2 = -1;
            if (param instanceof Literal)
            {
                Literal param2 = (Literal)expr.getArguments().get(1);
                if (param2.getLiteral() instanceof Number)
                {
                    arg2 = ((Number)param2.getLiteral()).intValue();
                }
                else
                {
                    throw new NucleusException(method + "(param1, param2) : param2 must be numeric!");
                }
View Full Code Here

TOP

Related Classes of org.datanucleus.query.expression.Literal

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.