/** * * Adds the proper ordering to the parser and returns the resulting expressions. * * @param ordering the orderBy string * @return an ordered expression array */ public Expression[] compileOrdering(String ordering) { if (ordering == null) { return null; } Node[] node = parser.parseOrder(ordering); Expression[] expr = new Expression[node.length]; for (int i = 0; i < node.length; i++) { ExpressionCompiler comp = new ExpressionCompiler(); comp.setSymbolTable(symbolTable); expr[i] = comp.compileOrderExpression(node[i]); expr[i].bind(symbolTable); } return expr; } }
/** * * Adds the proper ordering to the parser and returns the resulting expressions. * * @param ordering the orderBy string * @return an ordered expression array */ public Expression[] compileOrdering(String ordering) { if (ordering == null) { return null; } Node[] node = parser.parseOrder(ordering); Expression[] expr = new Expression[node.length]; for (int i = 0; i < node.length; i++) { ExpressionCompiler comp = new ExpressionCompiler(); comp.setSymbolTable(symbolTable); expr[i] = comp.compileOrderExpression(node[i]); expr[i].bind(symbolTable); } return expr; } }
private void handleContainsOperation(InvokeExpression invokeExpr, QueryData qd) { Expression param = (Expression) invokeExpr.getArguments().get(0); param.bind(getSymbolTable()); if (invokeExpr.getLeft() instanceof PrimaryExpression) { PrimaryExpression left = (PrimaryExpression) invokeExpr.getLeft(); // Make sure that the left expression is a collection List<String> tuples = getTuples(left, qd.compilation.getCandidateAlias()); if (tuples.size() == 1) { // Handle case of simple field name AbstractMemberMetaData mmd = qd.acmd.getMetaDataForMember(tuples.get(0)); if (mmd != null && !Collection.class.isAssignableFrom(mmd.getType())) { throw new UnsupportedDatastoreFeatureException("The 'contains' method is only for use with a Collection expression"); } } // treat contains as equality since that's how the low-level api does checks on multi-value properties. addLeftPrimaryExpression(left, Expression.OP_EQ, param, qd); } else if (invokeExpr.getLeft() instanceof ParameterExpression && param instanceof PrimaryExpression) { ParameterExpression pe = (ParameterExpression) invokeExpr.getLeft(); addLeftPrimaryExpression((PrimaryExpression) param, Expression.OP_EQ, pe, qd); } else { throw newUnsupportedQueryMethodException(invokeExpr); } }
/** * We fulfil "String.startsWith" by adding a >= filter for the method argument and a * < filter for the method argument translated into an upper limit for the scan. */ private void handleStartsWithOperation(InvokeExpression invokeExpr, QueryData qd) { Expression param = (Expression) invokeExpr.getArguments().get(0); param.bind(getSymbolTable()); if (invokeExpr.getLeft() instanceof PrimaryExpression) { PrimaryExpression left = (PrimaryExpression) invokeExpr.getLeft(); // Make sure that the left expression is a String List<String> tuples = getTuples(left, qd.compilation.getCandidateAlias()); if (tuples.size() == 1) { // Handle case of simple field name AbstractMemberMetaData mmd = qd.acmd.getMetaDataForMember(tuples.get(0)); if (mmd != null && !String.class.isAssignableFrom(mmd.getType())) { throw new UnsupportedDatastoreFeatureException("The 'startsWith' method is only for use with a String expression"); } } if (param instanceof Literal) { addPrefix(left, param, (String) ((Literal) param).getLiteral(), qd); return; } else if (param instanceof ParameterExpression) { Object parameterValue = getParameterValue(qd.parameters, (ParameterExpression) param); addPrefix(left, param, (String) parameterValue, qd); return; } } // Unsupported combination throw newUnsupportedQueryMethodException(invokeExpr); }