Package org.openrdf.query.resultio

Examples of org.openrdf.query.resultio.TupleQueryResultWriter


  @Override
  public void write(OutputStream out)
    throws IOException
  {
    try {
      TupleQueryResultWriter qrWriter = factory.getWriter(out);
      QueryResultUtil.report(tupleResult, qrWriter);
    }
    catch (StoreException e) {
      logger.error("Query evaluation error", e);
      throw new IOException("Query evaluation error: " + e.getMessage());
View Full Code Here


                            {
                                PrintWriter out = new PrintWriter( outputStream );
                                out.println( "<?xml version='1.0' encoding='UTF-8'?>" );
                                out.println( "<?xml-stylesheet type=\"text/xsl\" href=\"query/sparqlhtml.xsl\"?>" );
                                out.flush();
                                TupleQueryResultWriter qrWriter = new SPARQLResultsXMLWriter( new XMLWriter( outputStream )
                                {
                                    @Override
                                    public void startDocument()
                                        throws IOException
                                    {
                                        // Ignore
                                    }
                                } );
                                QueryResultUtil.report( queryResult, qrWriter );
                            }
                            catch( Exception e )
                            {
                                throw new IOException( e );
                            }
                            finally
                            {
                                try
                                {
                                    conn.close();
                                }
                                catch( RepositoryException e )
                                {
                                    // Ignore
                                }
                            }
                        }
                    };
                }
                else if( variant.getMediaType().equals( MediaType.APPLICATION_RDF_XML ) )
                {
                    return new OutputRepresentation( MediaType.APPLICATION_XML )
                    {
                        @Override
                        public void write( OutputStream outputStream )
                            throws IOException
                        {
                            try
                            {
                                TupleQueryResultWriter qrWriter = new SPARQLResultsXMLWriter( new XMLWriter( outputStream ) );
                                QueryResultUtil.report( queryResult, qrWriter );
                            }
                            catch( Exception e )
                            {
                                throw new IOException( e );
                            }
                            finally
                            {
                                try
                                {
                                    conn.close();
                                }
                                catch( RepositoryException e )
                                {
                                    // Ignore
                                }
                            }
                        }
                    };
                }
                else if( variant.getMediaType().equals( RestApplication.APPLICATION_SPARQL_JSON ) )
                {
                    return new OutputRepresentation( RestApplication.APPLICATION_SPARQL_JSON )
                    {
                        @Override
                        public void write( OutputStream outputStream )
                            throws IOException
                        {
                            try
                            {
                                TupleQueryResultWriter qrWriter = new SPARQLResultsJSONWriterFactory().getWriter( outputStream );
                                QueryResultUtil.report( queryResult, qrWriter );
                            }
                            catch( Exception e )
                            {
                                throw new IOException( e );
View Full Code Here

    setContentType(response, qrFormat);
    setContentDisposition(model, response, qrFormat);

    OutputStream out = response.getOutputStream();
    try {
      TupleQueryResultWriter qrWriter = qrWriterFactory.getWriter(out);
      TupleQueryResult tupleQueryResult = (TupleQueryResult)model.get(QUERY_RESULT_KEY);
      QueryResultUtil.report(tupleQueryResult, qrWriter);
    }
    catch (QueryEvaluationException e) {
      logger.error("Query evaluation error", e);
View Full Code Here

    }


    private TupleQueryResultWriter getTupleResultWriter(String format, OutputStream os) {
        //build outputwriter
        final TupleQueryResultWriter out;
        if(format == null) {
            out = QueryResultIO.createWriter(TupleQueryResultFormat.SPARQL, os);
        } else if(SparqlWritersHelper.parseSubType(format).equals("html")) {
            out = new SPARQLResultsHTMLWriter(os, templatingService);
        } else if(SparqlWritersHelper.parseSubType(format).equals("json")) {
View Full Code Here

        return result;
    }

    private TupleQueryResultWriter getTupleResultWriter(String format, OutputStream os) {
        //build outputwriter
        final TupleQueryResultWriter out;
        if(format == null) {
            out = QueryResultIO.createWriter(TupleQueryResultFormat.SPARQL, os);
        } else if(SparqlWritersHelper.parseSubType(format).equals("html")) {
            out = new SPARQLResultsHTMLWriter(os, templatingService);
        } else if(SparqlWritersHelper.parseSubType(format).equals("json")) {
View Full Code Here

            resultFormat = QueryResultIO.getWriterFormatForMIMEType(format);
            if(resultFormat == null) {
                throw new InvalidArgumentException("could not produce format "+format);
            }
        }
        TupleQueryResultWriter writer = QueryResultIO.createWriter(resultFormat, os);
        if(writer.getSupportedSettings().contains(SPARQLHTMLSettings.TEMPLATING_SERVICE)) {
            writer.getWriterConfig().set(SPARQLHTMLSettings.TEMPLATING_SERVICE, templatingService);
        }
        return writer;
    }
View Full Code Here

    }


    private TupleQueryResultWriter getTupleResultWriter(String format, OutputStream os) {
        //build outputwriter
        final TupleQueryResultWriter out;
        if(format == null) {
            out = new SPARQLResultsXMLWriter(os);
        } else if(parseSubType(format).equals("html")) {
            out = new SPARQLResultsHTMLWriter(os, templatingService);
        } else if(parseSubType(format).equals("json")) {
View Full Code Here

        return result;
    }

    private TupleQueryResultWriter getTupleResultWriter(String format, OutputStream os) {
        //build outputwriter
        final TupleQueryResultWriter out;
        if(format == null) {
            out = new SPARQLResultsXMLWriter(os);
        } else if(SparqlWritersHelper.parseSubType(format).equals("html")) {
            out = new SPARQLResultsHTMLWriter(os, templatingService);
        } else if(SparqlWritersHelper.parseSubType(format).equals("json")) {
View Full Code Here

TOP

Related Classes of org.openrdf.query.resultio.TupleQueryResultWriter

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.