Package xbird.xquery.expr.var

Examples of xbird.xquery.expr.var.Variable$PreEvaluatedVariable


            return clause;
        }

        @Override
        public XQExpression visit(VarRef ref, XQueryContext ctxt) throws XQueryException {
            final Variable var = ref.getValue();
            if(var instanceof BindingVariable) {
                if(!excludedVariableList.contains(var)) {
                    variablesHolder.add((BindingVariable) var);
                }
            }
View Full Code Here


        XQExpression orderExpr = other.getKeyExpr();
        if(!(orderExpr instanceof VarRef)) {
            return false;
        }
        VarRef orderingVarRef = (VarRef) orderExpr;
        Variable orderingVar = orderingVarRef.getValue();
        if(orderingVar != groupingVariable) {
            return false;
        }
        if(other.getCollation() != getCollation()) {
            return false;
View Full Code Here

        Enumeration<String> paramNames = req.getParameterNames();
        while(paramNames.hasMoreElements()) {
            String name = paramNames.nextElement();
            String value = req.getParameter(name);
            QualifiedName qname = QNameUtil.parse(name, XQSP_NSURI);
            Variable var = loadedModule.getVariable(qname);
            if(var != null && (var instanceof ExternalVariable)) {
                var.setResult(XString.valueOf(value));
            }
        }
        // execute
        final Sequence<? extends Item> result;
        try {
View Full Code Here

    }

    public void testLookupFunction() throws XQueryException, IllegalAccessException,
            NoSuchFieldException, NoSuchMethodException, InvocationTargetException {
        // params
        Variable v1 = new Variable.GlobalVariable(QNameTable.instantiate("", "p1"), new LiteralExpr(new XDouble(4)));
        v1.setType(DoubleType.DOUBLE);
        VarRef p1 = new VarRef(v1);
        List<VarRef> params = new LinkedList<VarRef>();
        params.add(p1);
        // function
        QualifiedName fname = QNameTable.instantiate("java:java.lang.Math", "sqrt");
View Full Code Here

    }

    @Override
    public XQExpression visit(CaseClause clause, XQueryContext ctxt) throws XQueryException {
        buf.append("case ");
        Variable v = clause.getVariable();
        if(v != null) {
            final String vname = v.getName();
            if(vname != null) {
                buf.append('$');
                buf.append(vname);
            }
            buf.append(" as ");
View Full Code Here

        // for, let
        List causes = expr.getClauses();
        int prev_type = -1;
        for(int i = 0; i < causes.size(); i++) {
            Binding cause = (Binding) causes.get(i);
            Variable var = cause.getVariable();
            final int type = cause.getExpressionType();
            if(i != 0) {
                if(prev_type == type) {
                    buf.append(", ");
                }
                lineFeed();
            }
            switch(type) {
                case Binding.FOR_CLAUSE:
                    if(prev_type != type) {
                        buf.append("for $"); // fist appearence.
                    } else {
                        buf.append("    $");
                    }
                    String varname = var.getName();
                    if(varname != null) {
                        buf.append(varname);
                        Variable posVar = ((ForClause) cause).getPositionVariable();
                        if(posVar != null) {
                            buf.append(" at $");
                            buf.append(posVar.getName());
                        }
                    } else {
                        assert (var instanceof BindingVariable || var instanceof PathVariable);
                    }
                    buf.append(" in ");
View Full Code Here

        return variable;
    }

    @Override
    public XQExpression visit(VarRef ref, XQueryContext ctxt) throws XQueryException {
        Variable var = ref.getValue();
        if(var instanceof PathVariable) {
            visit((PathVariable) var, ctxt);
        } else if(var instanceof ParametricVariable) {
            XQExpression expr = ((ParametricVariable) var).getValue();
            if(expr == null) {
                buf.append(var);
            } else {
                visit(expr, ctxt);
            }
        } else if(var instanceof ThreadedVariable) {
            ThreadedVariable threadVar = (ThreadedVariable) var;
            buf.append(threadVar);
            buf.append(" := ");
            indentln();
            XQExpression expr = threadVar.getValue();
            assert (expr != null);
            visit(expr, ctxt);
            indent--;
        } else if(var instanceof ShippedVariable) {
            buf.append(var.getValue());
        } else {
            buf.append(var);
        }
        return ref;
    }
View Full Code Here

        if(v_itor.hasNext()) {
            attrFeed("variable decls");
            indent++;
            do {
                lineFeed();
                Variable v = v_itor.next();
                v.visit(this, ctxt);
            } while(v_itor.hasNext());
            indent--;
        }

        final Iterator<UserFunction> f_itor = module.getLocalFunctions().iterator();
View Full Code Here

        Variable declareGlobalVariable(QualifiedName varName, XQExpression value)
                throws XQueryException {
            if(vars.containsKey(varName)) {
                throw new XQueryException("err:XQST0049", "Variable already defined: " + varName);
            }
            Variable v = new GlobalVariable(varName, value);
            vars.put(varName, v);
            localVars.add(varName);
            return v;
        }
View Full Code Here

            return v;
        }

        void putVariable(QualifiedName varName, Variable variable) throws XQueryException {
            if(variable instanceof GlobalVariable) {
                Variable var = vars.get(varName);
                if(var != null && !(var instanceof ExternalVariable)) {
                    throw new XQueryException("err:XQ0049", "Duplicate global variable: " + varName);
                }
            } else {
                if(localVars.contains(varName)) {
View Full Code Here

TOP

Related Classes of xbird.xquery.expr.var.Variable$PreEvaluatedVariable

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.