Examples of RDFFormat


Examples of org.openrdf.rio.RDFFormat

  private Model parseContent(Representation entity)
    throws ResourceException
  {
    String mimeType = entity.getMediaType().getName();
    RDFFormat rdfFormat = Rio.getParserFormatForMIMEType(mimeType);

    try {
      RDFParser parser = Rio.createParser(rdfFormat);

      Model model = new LinkedHashModel();
      parser.setRDFHandler(new StatementCollector(model));

      parser.parse(entity.getStream(), "");

      return model;
    }
    catch (UnsupportedRDFormatException e) {
      throw new ResourceException(CLIENT_ERROR_UNSUPPORTED_MEDIA_TYPE,
          "No RDF parser available for format " + rdfFormat.getName());
    }
    catch (RDFParseException e) {
      throw new ErrorInfoException(MALFORMED_DATA, e.getMessage());
    }
    catch (IOException e) {
View Full Code Here

Examples of org.openrdf.rio.RDFFormat

  private Model parseContent(Representation entity)
    throws ResourceException
  {
    String mimeType = entity.getMediaType().getName();
    RDFFormat rdfFormat = Rio.getParserFormatForMIMEType(mimeType);

    try {
      RDFParser parser = Rio.createParser(rdfFormat);

      Model model = new LinkedHashModel();
      parser.setRDFHandler(new StatementCollector(model));

      parser.parse(entity.getStream(), "");

      return model;
    }
    catch (UnsupportedRDFormatException e) {
      throw new ResourceException(CLIENT_ERROR_UNSUPPORTED_MEDIA_TYPE,
          "No RDF parser available for format " + rdfFormat.getName());
    }
    catch (RDFParseException e) {
      throw new ErrorInfoException(MALFORMED_DATA, e.getMessage());
    }
    catch (IOException e) {
View Full Code Here

Examples of org.openrdf.rio.RDFFormat

      repo.initialize();
      con = repo.getConnection();
    } catch (final RepositoryException e) {
      e.printStackTrace();
    }
    RDFFormat format = RDFFormat.RDFXML;
    if (type == FORMAT.N3)
      format = RDFFormat.N3;
    else if (type == FORMAT.NTriples)
      format = RDFFormat.N3;
    else if (type == FORMAT.Turtle)
View Full Code Here

Examples of org.openrdf.rio.RDFFormat

   * @throws SyntaxNotSupportedException When the Syntax could not be resolved to a
   *             RDFFormat.
   */
  public static RDFFormat getRDFFormat(Syntax syntax) throws SyntaxNotSupportedException {
      for (String mimeType : syntax.getMimeTypes()) {
          RDFFormat format = RDFFormat.forMIMEType(mimeType);
          if (format != null) {
              return format;
          }
      }
    throw new SyntaxNotSupportedException("This version of Sesame seems to have no "
View Full Code Here

Examples of org.openrdf.rio.RDFFormat

    ) {
        if (mimeTypeFromMetadata != null) {
            return mimeTypeFromMetadata;
        }

        final RDFFormat parserFormatForFileName = Rio.getParserFormatForFileName(fileName);
        if (parserFormatForFileName != null) {
            return MIMEType.parse(parserFormatForFileName.getDefaultMIMEType());
        }

        String extension = getExtension(fileName);
        if (extension == null) {
            // Assume index file on web server.
View Full Code Here

Examples of org.openrdf.rio.RDFFormat

            // force uncompressing the files (will try to guess if this option is not set)
            gzip = cmd.hasOption('z');

            // the format to use as fallback; will try to guess based on the filename.
            format = cmd.getOptionValue('f');
            final RDFFormat fmt;
            if (format != null) {
                fmt = RDFFormat.forMIMEType(format);
                if (fmt == null) {
                    throw new ParseException(String.format("Invalid/Unknown RDF format: %s, use one of %s", format, RDFFormat.values()));
                }
View Full Code Here

Examples of org.openrdf.rio.RDFFormat

    }



    private Repository parseRDFResponse(final URI resource, InputStream in, String contentType) throws RepositoryException, IOException, RDFParseException {
        RDFFormat format = RDFParserRegistry.getInstance().getFileFormatForMIMEType(contentType, RDFFormat.RDFXML);

        Repository triples = new SailRepository(new MemoryStore());
        triples.initialize();

        InterceptingRepositoryConnection con =
View Full Code Here

Examples of org.openrdf.rio.RDFFormat

 
  @Main(name="data", print=false)
  public DTGraph<String, String> load()
  {
   
    RDFFormat format = RDFFormat.forFileName(file);
   
    if(format == null)
      throw new RuntimeException("RDF file "+file+" not recognized");
     
    RDFDataSet testSet = new RDFFileDataSet(file, format);
View Full Code Here

Examples of org.openrdf.rio.RDFFormat

        String formatName = configuration.get(RDFInputFormat.FAUNUS_GRAPH_INPUT_RDF_FORMAT);
        if (null == formatName) {
            throw new RuntimeException("RDF format is required. Use " + RDFInputFormat.FAUNUS_GRAPH_INPUT_RDF_FORMAT);
        }
        RDFFormat format = formats.get(formatName);
        if (null == format) {
            throw new RuntimeException("unknown RDF format: " + formatName);
        }
        this.parser = Rio.createParser(format);
View Full Code Here

Examples of org.openrdf.rio.RDFFormat

        formats.put("trig", RDFFormat.TRIG);
        formats.put("turtle", RDFFormat.TURTLE);
    }

    public static RDFFormat getFormat(final String format) {
        RDFFormat ret = formats.get(format);
        if (null == ret)
            throw new IllegalArgumentException(format + " is an unsupported RDF file format. Use rdf-xml, n-triples, n-quads, turtle, n3, trix, or trig");
        else
            return ret;
    }
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.