Package org.openjena.riot.out

Examples of org.openjena.riot.out.NodeFormatterTTL


    {
        bw = out ;
        vars = variables ;
        pmap = prefixMapping ;
       
        nodeFormatter = new NodeFormatterTTL(null, pmap) ;
        needOutputVars = (vars != null ) && vars.size() > 0 ;
    }
View Full Code Here


    @Override
    public void format(OutputStream out, ResultSet resultSet)
    {
        try {
          //Use a Turtle formatter to format terms
          NodeFormatterTTL formatter = new NodeFormatterTTL(null, null);
         
            Writer w = FileUtils.asUTF8(out) ;
            w = new BufferedWriter(w) ;
           
            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) ;
            }
           
View Full Code Here

    {
        bw = out ;
        vars = variables ;
        pmap = prefixMapping ;
       
        nodeFormatter = new NodeFormatterTTL(null, pmap) ;
        needOutputVars = (vars != null ) && vars.size() > 0 ;
    }
View Full Code Here

    @Override
    public void format(OutputStream out, ResultSet resultSet)
    {
        try {
          //Use a Turtle formatter to format terms
          NodeFormatterTTL formatter = new NodeFormatterTTL(null, null);
         
            Writer w = FileUtils.asUTF8(out) ;
            w = new BufferedWriter(w) ;
           
            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) ;
            }
           
View Full Code Here

TOP

Related Classes of org.openjena.riot.out.NodeFormatterTTL

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.