Examples of XQExpression


Examples of xbird.xquery.expr.XQExpression

                    } else {
                        assert (var instanceof BindingVariable || var instanceof PathVariable);
                    }
                    buf.append(" in ");
                    //indentln();
                    XQExpression inExpr = ((ForClause) cause).getInExpr();
                    inExpr.visit(this, ctxt);
                    //indent--;
                    break;
                case Binding.LET_CLAUSE:
                    if(prev_type != type) {
                        buf.append("let $"); // fist appearence.
                    } else {
                        buf.append("    $");
                    }
                    buf.append(var.getName());
                    buf.append(" := ");
                    //indentln();
                    var.getValue().visit(this, ctxt);
                    //indent--;
                    break;
                default:
                    throw new IllegalStateException();
            }
            prev_type = type;
        }

        XQExpression filteredRet = expr.getFilteredReturnExpr();

        // where
        if(filteredRet == null) {
            XQExpression filter = expr.getWhereExpr();
            if(filter != null) {
                lineFeed();
                buf.append("where ");
                indentln();
                filter.visit(this, ctxt);
                indent--;
            }
        }

        // order by
        List orders = expr.getOrderSpecs();
        for(int i = 0; i < orders.size(); i++) {
            if(i == 0) {
                lineFeed();
                if(expr.isStableOrdering()) {
                    buf.append("stable ");
                }
                buf.append("order by");
            } else {
                buf.append(',');
            }
            indentln();
            OrderSpec spec = (OrderSpec) orders.get(i);
            spec.getKeyExpr().visit(this, ctxt);
            indent--;
            if(spec.isDescending()) {
                buf.append(" descending");
            }
            if(spec.isEmptyGreatest()) {
                buf.append(" empty greatest");
            }
            URI collation = spec.getCollation();
            if(collation != null) {
                buf.append(" collation ");
                buf.append(collation.toString());
            }
        }

        // return
        lineFeed();
        buf.append("return ");
        indentln();
        XQExpression ret = (filteredRet == null) ? expr.getReturnExpr() : filteredRet;
        ret.visit(this, ctxt);
        indent--;

        return expr;
    }
View Full Code Here

Examples of xbird.xquery.expr.XQExpression

        List params = call.getParams();
        for(int i = 0; i < params.size(); i++) {
            if(i != 0) {
                buf.append(", ");
            }
            XQExpression p = (XQExpression) params.get(i);
            p.visit(this, ctxt);
        }
        buf.append(')');
        return call;
    }
View Full Code Here

Examples of xbird.xquery.expr.XQExpression

        for(int i = 0; i < exprs.size(); i++) {
            if(i != 0) {
                buf.append(" or");
                lineFeed();
            }
            XQExpression e = (XQExpression) exprs.get(i);
            e.visit(this, ctxt);
        }
        return expr;
    }
View Full Code Here

Examples of xbird.xquery.expr.XQExpression

        if(rsig != Signature.PREPARED_QUERY) {
            throw new IllegalStateException("Illegal command is passed to PreparedQueryProcessor: "
                    + rsig);
        }
        final PreparedQueryRequest queryRequest = (PreparedQueryRequest) request;
        final XQExpression queryExpr = queryRequest.getCompiledExpression();
        if(queryExpr == null) {
            throw new IllegalStateException("query was null for: " + queryRequest);
        }

        final ThreadedVariableCollector collector = new ThreadedVariableCollector();
        try {
            collector.visit(queryExpr, null);
        } catch (XQueryException e) {
            throw new RemoteException("failed runnning ThreadVariables", e);
        }
        final DynamicContext dynEnv = new DynamicContext(new StaticContext());
        dynEnv.setQueryExpression(queryExpr);
        collector.invokeThreadedVariables(dynEnv); // TODO REVIEWME cancelling

        final Sequence<? extends Item> resultSeq;
        _runningThreads.put(rc, Thread.currentThread());
        try {
            resultSeq = queryExpr.eval(null, dynEnv);
        } catch (XQueryException e) {
            LOG.error("execute failed: \n" + queryExpr, e);
            rc.setFault(e);
            _resHandler.onResponse(rc);
            return;
View Full Code Here

Examples of xbird.xquery.expr.XQExpression

        final int steplen = steps.size();
        for(int i = 0; i < steplen; i++) {
            if(i != 0) {
                buf.append('/');
            }
            XQExpression expr = steps.get(i);
            expr.visit(this, ctxt);
        }
        /*
         if(steplen > 0) {
         XQExpression lastExpr = steps.get(steplen - 1);
         lastExpr.visit(this, ctxt);
View Full Code Here

Examples of xbird.xquery.expr.XQExpression

        buf.append('$');
        buf.append(binding.getName());

        buf.append(" in ");
        indentln();
        XQExpression inExpr = binding.getValue();
        inExpr.visit(this, ctxt);
        indent--;

        lineFeed();
        buf.append("satisfies");
        indentln();
View Full Code Here

Examples of xbird.xquery.expr.XQExpression

        for(int i = 0; i < exprs.size(); i++) {
            if(i != 0) {
                buf.append(", ");
                lineFeed();
            }
            XQExpression e = (XQExpression) exprs.get(i);
            e.visit(this, ctxt);
        }
        indent--;
        lineFeed();
        buf.append(')');
        return expr;
View Full Code Here

Examples of xbird.xquery.expr.XQExpression

    @Override
    public XQExpression visit(TextConstructor constructor, XQueryContext ctxt)
            throws XQueryException {
        header("TextConstructor");

        final XQExpression content = constructor.getContent();
        indentln();
        content.visit(this, ctxt);
        indent--;

        return constructor;
    }
View Full Code Here

Examples of xbird.xquery.expr.XQExpression

            CaseClause c = (CaseClause) cases.get(i);
            c.visit(this, ctxt);
        }
        lineFeed();
        buf.append("default:");
        XQExpression dc = expr.getDefaultClause();
        if(dc != null) {
            indentln();
            dc.visit(this, ctxt);
            indent--;
        }
        indent--;
        lineFeed();
        buf.append('}');
View Full Code Here

Examples of xbird.xquery.expr.XQExpression

        Type type = variable.getType();
        if(type != null) {
            buf.append(" as ");
            buf.append(type);
        }
        XQExpression value = variable.getValue();
        buf.append(" := ");
        if(value != null) { // may be null with funcall
            value.visit(this, ctxt);
        }
        return variable;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.