Package com.hp.hpl.jena.sparql.expr

Examples of com.hp.hpl.jena.sparql.expr.Expr


    void appendNamedExprList(Query query, IndentedWriter sb, VarExprList namedExprs)
    {
        boolean first = true ;
        for ( Var var : namedExprs.getVars() )
        {
            Expr expr = namedExprs.getExpr(var) ;
            if ( ! first )
                sb.print(" ") ;
           
            if ( expr != null )
            {
                // The following are safe to write without ()
                // Compare/merge with fmtExpr.format
                boolean needParens = true ;
               
                if ( expr.isFunction() )
                    needParens = false ;
//                else if ( expr instanceof E_Aggregator )
//                    // Aggregators are variables (the function maps to an internal variable
//                    // that is accesses by the E_Aggregator
//                    needParens = false ;
                else if ( expr.isVariable() )
                    needParens = false ;
               
                if ( ! Var.isAllocVar(var) )
                    // AS ==> need parens
                    needParens = true  ;
View Full Code Here


    @Override
    public void visit(ElementFilter el)
    {
        out.print("FILTER ") ;
        Expr expr = el.getExpr() ;
        FmtExprSPARQL v = new FmtExprSPARQL(out, context) ;
       
        // This assumes that complex expressions are bracketted
        // (parens) as necessary except for some cases:
        //   Plain variable or constant
       
        boolean addParens = false ;
        if ( expr.isVariable() )
            addParens = true ;
        if ( expr.isConstant() )
            addParens = true ;
       
        if ( addParens )
            out.print("( ") ;
        v.format(expr) ;
View Full Code Here

                direction = Query.ORDER_ASCENDING ;
            else
                direction = Query.ORDER_DESCENDING ;
            item = item.getList().get(1) ;
        }
        Expr expr = BuilderExpr.buildExpr(item) ;
        if ( expr.isVariable() )
            return new SortCondition(expr.getExprVar().asVar(), direction) ;
        else
            return new SortCondition(expr, direction) ;
    }
View Full Code Here

    }

    @Override
    protected void runTest() throws Throwable
    {
        Expr expr = null ;
        try {
            expr = parse(exprString) ;
        }
        catch (Error err)
        {
            fail("Error thrown in parse: "+err) ;
        }
        catch (Exception ex)
        {
            if ( failureMode != TestExpr.PARSE_FAIL )
                fail("Unexpected parsing failure: "+ex) ;
           
            checkException(expr, ex) ;
            return ;
        }

        if ( failureMode == TestExpr.PARSE_FAIL )
        {
            fail("Test should have failed in parsing: "+expr) ;
            return ;
        }
       
        Expr expr2 = expr.deepCopy() ;
        if ( ! expr.equals(expr2) )
        {
            System.out.println("Expr:  "+expr) ;
            System.out.println("Expr2: "+expr2) ;
            assertEquals(expr, expr2) ;
View Full Code Here

       
        // ---- Build expression
        bp.add(new Triple(var_x, NodeFactory.createURI(BASE+"p"), var_z)) ;
        Op op = new OpBGP(bp) ;
        //Expr expr = ExprUtils.parse("?z < 2 ") ;
        Expr expr = new E_LessThan(new ExprVar(var_z), NodeValue.makeNodeInteger(2)) ;
        op = OpFilter.filter(expr, op) ;

        // ---- Example setup
        Model m = makeModel() ;
        m.write(System.out, "TTL") ;
View Full Code Here

                pmap.setNsPrefix("", "http://example/") ;
                pmap.setNsPrefix("ex", "http://example/ns#") ;
//              Node n = asNode() ;
//              return makeNode(n) ;

                Expr expr = ExprUtils.parse(exprStr, pmap) ;
                if ( verbose )
                    System.out.print(expr.toString()+" => ") ;
               
                if ( actionPrint )
                {
                    if ( actionPrintSPARQL )
                        System.out.println(ExprUtils.fmtSPARQL(expr)) ;
                    if ( actionPrintPrefix )
                        WriterSSE.out(IndentedWriter.stdout, expr, new Prologue(pmap)) ;
                    continue ;
                }
               
                try {
                    if ( actionCopySubstitute )
                    {
                        Expr e = ExprLib.foldConstants(expr) ;
                        System.out.println(e) ;
                    }
                    else
                    {
                        // Default action
View Full Code Here

     * that is placed.
     */
   
    private static Op insertAnyFilter$(ExprList unplacedExprs, Collection<Var> patternVarsScope, Op op) {
        for (Iterator<Expr> iter = unplacedExprs.iterator(); iter.hasNext();) {
            Expr expr = iter.next() ;
            // Cache
            Set<Var> exprVars = expr.getVarsMentioned() ;
            if ( patternVarsScope.containsAll(exprVars) ) {
                if ( op == null )
                    op = OpTable.unit() ;
                op = OpFilter.filter(expr, op) ;
                iter.remove() ;
View Full Code Here

    private static Op buildFilter(ExprList exprs, Op op) {
        if ( exprs == null || exprs.isEmpty() )
            return op ;

        for (Iterator<Expr> iter = exprs.iterator(); iter.hasNext();) {
            Expr expr = iter.next() ;
            if ( op == null )
                op = OpTable.unit() ;
            op = OpFilter.filter(expr, op) ;
        }
        return op ;
View Full Code Here

    // ---- Utilities

    /** For any expression now in scope, wrap the op with a filter */
    private static Op insertAnyFilter(ExprList exprs, Set<Var> patternVarsScope, Op op) {
        for (Iterator<Expr> iter = exprs.iterator(); iter.hasNext();) {
            Expr expr = iter.next();
            // Cache
            Set<Var> exprVars = expr.getVarsMentioned();
            if (patternVarsScope.containsAll(exprVars)) {
                if (op == null)
                    op = OpTable.unit();
                op = OpFilter.filter(expr, op);
                iter.remove();
View Full Code Here

    private static Op buildFilter(ExprList exprs, Op op) {
        if (exprs.isEmpty())
            return op;

        for (Iterator<Expr> iter = exprs.iterator(); iter.hasNext();) {
            Expr expr = iter.next();
            if (op == null)
                op = OpTable.unit();
            op = OpFilter.filter(expr, op);
            iter.remove();
        }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.sparql.expr.Expr

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.