/** * Parses the content of the <code>resource</code> file * guessing the content format from the extension. * * @param resource resource name. * @return the statements declared within the resource file. * @throws java.io.IOException if an error occurs while reading file. */ public static Statement[] parseRDF(String resource) throws IOException { final int extIndex = resource.lastIndexOf('.'); if(extIndex == -1) throw new IllegalArgumentException("Error while detecting the extension in resource name " + resource); final String extension = resource.substring(extIndex + 1); return parseRDF( getFormatByExtension(extension).orElseThrow(Rio.unsupportedFormat(extension)) , RDFUtils.class.getResourceAsStream(resource) ); }
@Override public void add(File file, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException { if (baseURI == null) { // default baseURI to file baseURI = file.toURI().toString(); } if (dataFormat == null) { dataFormat = Rio.getParserFormatForFileName(file.getName()).orElseThrow( Rio.unsupportedFormat(file.getName())); } try (InputStream in = new FileInputStream(file)) { add(in, baseURI, dataFormat, contexts); } }
public void add(File file, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException { if (baseURI == null) { // default baseURI to file baseURI = file.toURI().toString(); } if (dataFormat == null) { dataFormat = Rio.getParserFormatForFileName(file.getName()).orElseThrow( Rio.unsupportedFormat(file.getName())); } InputStream in = new FileInputStream(file); try { add(in, baseURI, dataFormat, contexts); } finally { in.close(); } }
public void add(File file, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException { if (baseURI == null) { // default baseURI to file baseURI = file.toURI().toString(); } if (dataFormat == null) { dataFormat = Rio.getParserFormatForFileName(file.getName()).orElseThrow( Rio.unsupportedFormat(file.getName())); } InputStream in = new FileInputStream(file); try { add(in, baseURI, dataFormat, contexts); } finally { in.close(); } }
@Override public RDFFormat convert(String value) { return RDFWriterRegistry.getInstance().getFileFormatForMIMEType(value).orElseThrow(Rio.unsupportedFormat(value)); }
/** * Convenience methods for creating RDFWriter objects. This method uses the registry returned by * {@link RDFWriterRegistry#getInstance()} to get a factory for the specified format and uses this factory * to create the appropriate writer. * * @throws UnsupportedRDFormatException * If no writer is available for the specified RDF format. */ public static RDFWriter createWriter(RDFFormat format, OutputStream out) throws UnsupportedRDFormatException { RDFWriterFactory factory = RDFWriterRegistry.getInstance().get(format).orElseThrow( Rio.unsupportedFormat(format)); return factory.getWriter(out); }
/** * Convenience methods for creating RDFParser objects. This method uses the registry returned by * {@link RDFParserRegistry#getInstance()} to get a factory for the specified format and uses this factory * to create the appropriate parser. * * @throws UnsupportedRDFormatException * If no parser is available for the specified RDF format. */ public static RDFParser createParser(RDFFormat format) throws UnsupportedRDFormatException { RDFParserFactory factory = RDFParserRegistry.getInstance().get(format).orElseThrow( Rio.unsupportedFormat(format)); return factory.getParser(); }
/** * Convenience methods for creating RDFParser objects. This method uses the registry returned by * {@link RDFParserRegistry#getInstance()} to get a factory for the specified format and uses this factory * to create the appropriate parser. * * @throws UnsupportedRDFormatException * If no parser is available for the specified RDF format. */ public static RDFParser createParser(RDFFormat format) throws UnsupportedRDFormatException { RDFParserFactory factory = RDFParserRegistry.getInstance().get(format).orElseThrow( Rio.unsupportedFormat(format)); return factory.getParser(); }
/** * Convenience methods for creating RDFWriter objects. This method uses the registry returned by * {@link RDFWriterRegistry#getInstance()} to get a factory for the specified format and uses this factory * to create the appropriate writer. * * @throws UnsupportedRDFormatException * If no writer is available for the specified RDF format. */ public static RDFWriter createWriter(RDFFormat format, Writer writer) throws UnsupportedRDFormatException { RDFWriterFactory factory = RDFWriterRegistry.getInstance().get(format).orElseThrow( Rio.unsupportedFormat(format)); return factory.getWriter(writer); }
/** * Convenience methods for creating RDFWriter objects. This method uses the registry returned by * {@link RDFWriterRegistry#getInstance()} to get a factory for the specified format and uses this factory * to create the appropriate writer. * * @throws UnsupportedRDFormatException * If no writer is available for the specified RDF format. */ public static RDFWriter createWriter(RDFFormat format, OutputStream out) throws UnsupportedRDFormatException { RDFWriterFactory factory = RDFWriterRegistry.getInstance().get(format).orElseThrow( Rio.unsupportedFormat(format)); return factory.getWriter(out); }
/** * Convenience methods for creating RDFWriter objects. This method uses the registry returned by * {@link RDFWriterRegistry#getInstance()} to get a factory for the specified format and uses this factory * to create the appropriate writer. * * @throws UnsupportedRDFormatException * If no writer is available for the specified RDF format. */ public static RDFWriter createWriter(RDFFormat format, Writer writer) throws UnsupportedRDFormatException { RDFWriterFactory factory = RDFWriterRegistry.getInstance().get(format).orElseThrow( Rio.unsupportedFormat(format)); return factory.getWriter(writer); }
/** * Convenience methods for creating RDFParser objects. This method uses the registry returned by * {@link RDFParserRegistry#getInstance()} to get a factory for the specified format and uses this factory * to create the appropriate parser. * * @throws UnsupportedRDFormatException * If no parser is available for the specified RDF format. */ public static RDFParser createParser(RDFFormat format) throws UnsupportedRDFormatException { RDFParserFactory factory = RDFParserRegistry.getInstance().get(format).orElseThrow( Rio.unsupportedFormat(format)); return factory.getParser(); }
/** * Convenience methods for creating RDFWriter objects. This method uses the registry returned by * {@link RDFWriterRegistry#getInstance()} to get a factory for the specified format and uses this factory * to create the appropriate writer. * * @throws UnsupportedRDFormatException * If no writer is available for the specified RDF format. */ public static RDFWriter createWriter(RDFFormat format, OutputStream out) throws UnsupportedRDFormatException { RDFWriterFactory factory = RDFWriterRegistry.getInstance().get(format).orElseThrow( Rio.unsupportedFormat(format)); return factory.getWriter(out); }
/** * Convenience methods for creating RDFWriter objects. This method uses the registry returned by * {@link RDFWriterRegistry#getInstance()} to get a factory for the specified format and uses this factory * to create the appropriate writer. * * @throws UnsupportedRDFormatException * If no writer is available for the specified RDF format. */ public static RDFWriter createWriter(RDFFormat format, Writer writer) throws UnsupportedRDFormatException { RDFWriterFactory factory = RDFWriterRegistry.getInstance().get(format).orElseThrow( Rio.unsupportedFormat(format)); return factory.getWriter(writer); }
/** * Convenience methods for creating RDFWriter objects. This method uses the registry returned by * {@link RDFWriterRegistry#getInstance()} to get a factory for the specified format and uses this factory * to create the appropriate writer. * * @throws UnsupportedRDFormatException * If no writer is available for the specified RDF format. * @throws URISyntaxException * If the baseURI is invalid */ public static RDFWriter createWriter(RDFFormat format, OutputStream out, String baseURI) throws UnsupportedRDFormatException, URISyntaxException { RDFWriterFactory factory = RDFWriterRegistry.getInstance().get(format).orElseThrow( Rio.unsupportedFormat(format)); return factory.getWriter(out, baseURI); }
/** * Convenience methods for creating RDFWriter objects. This method uses the registry returned by * {@link RDFWriterRegistry#getInstance()} to get a factory for the specified format and uses this factory * to create the appropriate writer. * * @throws UnsupportedRDFormatException * If no writer is available for the specified RDF format. * @throws URISyntaxException * If the baseURI is invalid */ public static RDFWriter createWriter(RDFFormat format, Writer writer, String baseURI) throws UnsupportedRDFormatException, URISyntaxException { RDFWriterFactory factory = RDFWriterRegistry.getInstance().get(format).orElseThrow( Rio.unsupportedFormat(format)); return factory.getWriter(writer, baseURI); }
/** * Convenience methods for creating RDFWriter objects. This method uses the registry returned by * {@link RDFWriterRegistry#getInstance()} to get a factory for the specified format and uses this factory * to create the appropriate writer. * * @throws UnsupportedRDFormatException * If no writer is available for the specified RDF format. * @throws URISyntaxException * If the baseURI is invalid */ public static RDFWriter createWriter(RDFFormat format, Writer writer, String baseURI) throws UnsupportedRDFormatException, URISyntaxException { RDFWriterFactory factory = RDFWriterRegistry.getInstance().get(format).orElseThrow( Rio.unsupportedFormat(format)); return factory.getWriter(writer, baseURI); }
/** * Convenience methods for creating RDFWriter objects. This method uses the registry returned by * {@link RDFWriterRegistry#getInstance()} to get a factory for the specified format and uses this factory * to create the appropriate writer. * * @throws UnsupportedRDFormatException * If no writer is available for the specified RDF format. * @throws URISyntaxException * If the baseURI is invalid */ public static RDFWriter createWriter(RDFFormat format, Writer writer, String baseURI) throws UnsupportedRDFormatException, URISyntaxException { RDFWriterFactory factory = RDFWriterRegistry.getInstance().get(format).orElseThrow( Rio.unsupportedFormat(format)); return factory.getWriter(writer, baseURI); }
/** * Convenience methods for creating RDFWriter objects. This method uses the registry returned by * {@link RDFWriterRegistry#getInstance()} to get a factory for the specified format and uses this factory * to create the appropriate writer. * * @throws UnsupportedRDFormatException * If no writer is available for the specified RDF format. * @throws URISyntaxException * If the baseURI is invalid */ public static RDFWriter createWriter(RDFFormat format, OutputStream out, String baseURI) throws UnsupportedRDFormatException, URISyntaxException { RDFWriterFactory factory = RDFWriterRegistry.getInstance().get(format).orElseThrow( Rio.unsupportedFormat(format)); return factory.getWriter(out, baseURI); }
/** * Convenience methods for creating RDFWriter objects. This method uses the registry returned by * {@link RDFWriterRegistry#getInstance()} to get a factory for the specified format and uses this factory * to create the appropriate writer. * * @throws UnsupportedRDFormatException * If no writer is available for the specified RDF format. * @throws URISyntaxException * If the baseURI is invalid */ public static RDFWriter createWriter(RDFFormat format, OutputStream out, String baseURI) throws UnsupportedRDFormatException, URISyntaxException { RDFWriterFactory factory = RDFWriterRegistry.getInstance().get(format).orElseThrow( Rio.unsupportedFormat(format)); return factory.getWriter(out, baseURI); }