Examples of RDFWriterFactory


Examples of org.openrdf.rio.RDFWriterFactory

  }

  public void sendModel(final Model model) {
    final RDFFormat dataFormat = pool.getPreferredRDFFormat();
    final Charset charset = dataFormat.hasCharset() ? dataFormat.getCharset() : Charset.forName("UTF-8");
    final RDFWriterFactory factory = RDFWriterRegistry.getInstance().get(dataFormat);
    sendEntity(new RequestEntity() {

      public long getContentLength() {
        return -1; // don't know
      }

      public String getContentType() {
        return dataFormat.getDefaultMIMEType() + "; charset=" + charset.name();
      }

      public boolean isRepeatable() {
        return false;
      }

      public void writeRequest(OutputStream out)
        throws IOException
      {
        OutputStreamWriter writer = new OutputStreamWriter(out, charset);
        RDFWriter rdf = factory.getWriter(writer);
        try {
          rdf.startRDF();
          for (Map.Entry<String, String> ns : model.getNamespaces().entrySet()) {
            rdf.handleNamespace(ns.getKey(), ns.getValue());
          }
View Full Code Here

Examples of org.openrdf.rio.RDFWriterFactory

    MemorySPARQLQueryTest.suite().run(testResult);
    SPARQLSyntaxTest.suite().run(testResult);

    con.commit();

    RDFWriterFactory factory = RDFWriterRegistry.getInstance().get(RDFFormat.TURTLE);
    File outFile = File.createTempFile("sesame-sparql-compliance", "."
        + RDFFormat.TURTLE.getDefaultFileExtension());
    FileOutputStream out = new FileOutputStream(outFile);
    try {
      con.export(factory.getWriter(out));
    }
    finally {
      out.close();
    }
View Full Code Here

Examples of org.openrdf.rio.RDFWriterFactory

    }

    private void writeN3( Iterable<Statement> graph )
        throws RDFHandlerException, IOException
    {
        RDFWriterFactory writerFactory = new N3WriterFactory();
        RDFWriter writer = writerFactory.getWriter( System.out );
        writeOutput( writer, graph );
    }
View Full Code Here

Examples of org.openrdf.rio.RDFWriterFactory

    }

    private void writeXml( Iterable<Statement> graph )
        throws RDFHandlerException, IOException
    {
        RDFWriterFactory writerFactory = new RDFXMLWriterFactory();
        RDFWriter writer = writerFactory.getWriter( System.out );
        writeOutput( writer, graph );
    }
View Full Code Here

Examples of org.openrdf.rio.RDFWriterFactory

    @Override
    public void serialize( Iterable<Statement> graph, Writer out, String[] namespacePrefixes, String[] namespaces )
        throws RDFHandlerException
    {
        RDFWriterFactory writerFactory;
        try
        {
            writerFactory = writerFactoryClass.newInstance();
        }
        catch( InstantiationException e )
        {
            throw new InternalError();
        }
        catch( IllegalAccessException e )
        {
            throw new InternalError();
        }
        RDFWriter writer = writerFactory.getWriter( out );
        writer.startRDF();
        for( int i = 0; i < namespacePrefixes.length; i++ )
        {
            String namespacePrefix = namespacePrefixes[ i ];
            String namespace = namespaces[ i ];
View Full Code Here

Examples of org.openrdf.rio.RDFWriterFactory

    URI pred = (URI)model.get(PREDICATE_KEY);
    Value obj = (Value)model.get(OBJECT_KEY);
    Resource[] contexts = (Resource[])model.get(CONTEXTS_KEY);
    boolean useInferencing = (Boolean)model.get(USE_INFERENCING_KEY);

    RDFWriterFactory rdfWriterFactory = (RDFWriterFactory)model.get(FACTORY_KEY);

    RDFFormat rdfFormat = rdfWriterFactory.getRDFFormat();

    try {
      OutputStream out = response.getOutputStream();
      RDFWriter rdfWriter = rdfWriterFactory.getWriter(out);

      response.setStatus(SC_OK);

      String mimeType = rdfFormat.getDefaultMIMEType();
      if (rdfFormat.hasCharset()) {
View Full Code Here

Examples of org.openrdf.rio.RDFWriterFactory

  @SuppressWarnings("unchecked")
  public void render(Map model, HttpServletRequest request, HttpServletResponse response)
    throws IOException
  {
    RDFWriterFactory rdfWriterFactory = (RDFWriterFactory)model.get(FACTORY_KEY);
    RDFFormat rdfFormat = rdfWriterFactory.getRDFFormat();

    response.setStatus(SC_OK);
    setContentType(response, rdfFormat);
    setContentDisposition(model, response, rdfFormat);

    OutputStream out = response.getOutputStream();
    try {
      RDFWriter rdfWriter = rdfWriterFactory.getWriter(out);
      GraphQueryResult graphQueryResult = (GraphQueryResult)model.get(QUERY_RESULT_KEY);
      QueryResultUtil.report(graphQueryResult, rdfWriter);
    }
    catch (QueryEvaluationException e) {
      logger.error("Query evaluation error", e);
View Full Code Here

Examples of org.openrdf.rio.RDFWriterFactory

    URI pred = ProtocolUtil.parseURIParam(request, PREDICATE_PARAM_NAME, vf);
    Value obj = ProtocolUtil.parseValueParam(request, OBJECT_PARAM_NAME, vf);
    Resource[] contexts = ProtocolUtil.parseContextParam(request, CONTEXT_PARAM_NAME, vf);
    boolean useInferencing = ProtocolUtil.parseBooleanParam(request, INCLUDE_INFERRED_PARAM_NAME, true);

    RDFWriterFactory rdfWriterFactory = ProtocolUtil.getAcceptableService(request, response,
        RDFWriterRegistry.getInstance());

    Map<String, Object> model = new HashMap<String, Object>();
    model.put(ExportStatementsView.SUBJECT_KEY, subj);
    model.put(ExportStatementsView.PREDICATE_KEY, pred);
View Full Code Here

Examples of org.openrdf.rio.RDFWriterFactory

    ManifestTest.suite().run(testResult);
    SPARQLSyntaxTest.suite().run(testResult);

    con.setAutoCommit(true);

    RDFWriterFactory factory = RDFWriterRegistry.getInstance().get(RDFFormat.TURTLE);
    File outFile = File.createTempFile("sesame-sparql-compliance", "."
        + RDFFormat.TURTLE.getDefaultFileExtension());
    FileOutputStream out = new FileOutputStream(outFile);
    try {
      con.export(factory.getWriter(out));
    }
    finally {
      out.close();
    }
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.