Package org.openrdf.rio

Examples of org.openrdf.rio.RDFWriter


    @Test
    public void testRDFDump() throws Exception {
        Repository repo = new SailRepository(sail);
        RepositoryConnection rc = repo.getConnection();
        try {
            RDFWriter w = Rio.createWriter(RDFFormat.TURTLE, System.out);
            rc.export(w);
        } finally {
            rc.close();
        }
    }
View Full Code Here


        @Override
        public void exportReadableToStream( PrintStream out )
            throws IOException
        {
            RDFWriter rdfWriter = Rio.createWriter( RDFFormat.TRIG, out );
            try
            {
                final RepositoryConnection connection = repository.getConnection();
                try
                {
View Full Code Here

        @Override
        public void exportFormalToWriter( PrintWriter out )
            throws IOException
        {
            RDFWriter rdfWriter = Rio.createWriter( RDFFormat.RDFXML, out );
            try
            {
                final RepositoryConnection connection = repository.getConnection();
                try
                {
View Full Code Here

            Repository model = RdfExporter.buildModel(project, engine, visitor);
            StringWriter sw = new StringWriter();
            try{
              RepositoryConnection con = model.getConnection();
              try{
                RDFWriter w = Rio.createWriter(RDFFormat.TURTLE, sw);
                for(Vocabulary v:schema.getPrefixesMap().values()){
                  w.handleNamespace(v.getName(), v.getUri());
                }
                con.export(w);
          }finally{
                con.close();
              }
View Full Code Here

    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

    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

        }
        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 ];
            writer.handleNamespace( namespacePrefix, namespace );
        }
        for( Statement st : graph )
        {
            writer.handleStatement( st );
        }
        writer.endRDF();
    }
View Full Code Here

   *         If an unsupported query result file format was specified.
   */
  public static void write(GraphQueryResult gqr, RDFFormat format, OutputStream out)
    throws IOException, RDFHandlerException, UnsupportedRDFormatException, QueryEvaluationException
  {
    RDFWriter writer = Rio.createWriter(format, out);
    try {
      QueryResultUtil.report(gqr, writer);
    }
    catch (RDFHandlerException e) {
      if (e.getCause() instanceof IOException) {
View Full Code Here

      if (format.getDefaultFileExtension() != null) {
        filename += "." + format.getDefaultFileExtension();
      }
      response.setHeader("Content-Disposition", "attachment; filename=" + filename);

      RDFWriter writer = Rio.createWriter(format, response.getOutputStream());

      conn = repo.getConnection();
      conn.exportStatements(settings.getSubject(), settings.getPredicate(), settings.getObject(),
          settings.isIncludeInferred(), writer, settings.getContexts());
    }
View Full Code Here

    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

TOP

Related Classes of org.openrdf.rio.RDFWriter

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.