Examples of AWriter


Examples of org.apache.jena.atlas.io.AWriter

    public void format(OutputStream out, ResultSet resultSet)
    {
        //Use a Turtle formatter to format terms
        NodeFormatterTTL formatter = new NodeFormatterTTL(null, null);

        AWriter w = IO.wrapUTF8(out) ;

        String sep = null ;
        List<String> varNames = resultSet.getResultVars() ;
        List<Var> vars = new ArrayList<Var>(varNames.size()) ;

        // writes the variables on the first line
        for( String v : varNames )
        {
            if ( sep != null )
                w.write(sep) ;
            else
                sep = SEP ;
            Var var = Var.alloc(v) ;
            w.write(var.toString()) ;
            vars.add(var) ;
        }
        w.write(NL) ;

        // writes one binding by line
        for ( ; resultSet.hasNext() ; )
        {
            sep = null ;
            Binding b = resultSet.nextBinding() ;

            for( Var v : vars )
            {
                if ( sep != null )
                    w.write(sep) ;
                sep = SEP ;

                Node n = b.get(v) ;
                if ( n != null )
                {
                    // This will not include a raw tab.
                    formatter.format(w, n);
                }
            }
            w.write(NL) ;
        }

        w.flush() ;
    }
View Full Code Here

Examples of org.apache.jena.atlas.io.AWriter

    public void format(OutputStream out, ResultSet resultSet)
    {
        //Use a Turtle formatter to format terms
        NodeFormatterTTL formatter = new NodeFormatterTTL(null, null);

        AWriter w = IO.wrapUTF8(out) ;

        String sep = null ;
        List<String> varNames = resultSet.getResultVars() ;
        List<Var> vars = new ArrayList<>(varNames.size()) ;

        // writes the variables on the first line
        for( String v : varNames )
        {
            if ( sep != null )
                w.write(sep) ;
            else
                sep = SEP ;
            Var var = Var.alloc(v) ;
            w.write(var.toString()) ;
            vars.add(var) ;
        }
        w.write(NL) ;

        // writes one binding by line
        for ( ; resultSet.hasNext() ; )
        {
            sep = null ;
            Binding b = resultSet.nextBinding() ;

            for( Var v : vars )
            {
                if ( sep != null )
                    w.write(sep) ;
                sep = SEP ;

                Node n = b.get(v) ;
                if ( n != null )
                {
                    // This will not include a raw tab.
                    formatter.format(w, n);
                }
            }
            w.write(NL) ;
        }

        w.flush() ;
    }
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.