/** * * Returns all the available {@link RDFFormat}s. * * @return an unmodifiable collection of formats. */ public static Collection<RDFFormat> getFormats() { return RDFParserRegistry.getInstance().getKeys(); }
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); for (RDFFormat f : RDFParserRegistry.getInstance().getKeys()) { if (f.getName().equals(formatName)) { format = f; return; } } }
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); for (RDFFormat f : RDFParserRegistry.getInstance().getKeys()) { if (f.getName().equals(formatName)) { rioFormat = f; return; } } }
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); for (RDFFormat f : RDFParserRegistry.getInstance().getKeys()) { if (f.getName().equals(formatName)) { format = f; return; } } }
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); for (RDFFormat f : RDFParserRegistry.getInstance().getKeys()) { if (f.getName().equals(formatName)) { rioFormat = f; return; } } }
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); for (RDFFormat f : RDFParserRegistry.getInstance().getKeys()) { if (f.getName().equals(formatName)) { format = f; return; } } }
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); for (RDFFormat f : RDFParserRegistry.getInstance().getKeys()) { if (f.getName().equals(formatName)) { format = f; return; } } }
/** * Tries to match a MIME type against the list of RDF formats that can be parsed. * * @param mimeType * A MIME type, e.g. "application/rdf+xml". * @return An RDFFormat object if a match was found, or {@link Optional#empty()} otherwise. * @see #getParserFormatForMIMEType(String, RDFFormat) */ public static Optional<RDFFormat> getParserFormatForMIMEType(String mimeType) { return RDFFormat.matchMIMEType(mimeType, RDFParserRegistry.getInstance().getKeys()); }
private RDFFormat findRDFFormat(final String s) { RDFFormat format = formatsByName.get(s.toLowerCase()); if (null != format) { return format; } Optional<RDFFormat> f; RDFParserRegistry registry = RDFParserRegistry.getInstance(); f = registry.getFileFormatForMIMEType(s); if (!f.isPresent()) { f = registry.getFileFormatForFileName("example." + s); } if (!f.isPresent()) { throw new IllegalArgumentException("no matching RDF format for '" + s + "' (" + "supported formats are: " + getFormats(registry) + ")"); } return f.get(); }
/** * Tries to match a MIME type against the list of RDF formats that can be parsed. * * @param mimeType * A MIME type, e.g. "application/rdf+xml". * @return An RDFFormat object if a match was found, or {@link Optional#empty()} otherwise. * @see #getParserFormatForMIMEType(String, RDFFormat) */ public static Optional<RDFFormat> getParserFormatForMIMEType(String mimeType) { return RDFFormat.matchMIMEType(mimeType, RDFParserRegistry.getInstance().getKeys()); }
private static String listRDF() { StringBuilder sb = new StringBuilder(); for (RDFFormat fmt : RDFParserRegistry.getInstance().getKeys()) { sb.append("* ").append(fmt.getName()).append(" ("); boolean first = true; for (String ext : fmt.getFileExtensions()) { if (first) { first = false; } else { sb.append(", "); } sb.append('.').append(ext); } sb.append(")\n"); } return sb.toString(); }
/** * Tries to match the extension of a file name against the list of RDF formats that can be parsed. * * @param fileName * A file name. * @return An RDFFormat object if a match was found, or {@link Optional#empty()} otherwise. * @see #getParserFormatForFileName(String, RDFFormat) */ public static Optional<RDFFormat> getParserFormatForFileName(String fileName) { return RDFFormat.matchFileName(fileName, RDFParserRegistry.getInstance().getKeys()); }
/** * Tries to match the extension of a file name against the list of RDF formats that can be parsed. * * @param fileName * A file name. * @return An RDFFormat object if a match was found, or {@link Optional#empty()} otherwise. * @see #getParserFormatForFileName(String, RDFFormat) */ public static Optional<RDFFormat> getParserFormatForFileName(String fileName) { return RDFFormat.matchFileName(fileName, RDFParserRegistry.getInstance().getKeys()); }
/** * Tries to match the extension of a file name against the list of RDF formats that can be parsed. * * @param fileName * A file name. * @return An RDFFormat object if a match was found, or {@link Optional#empty()} otherwise. * @see #getParserFormatForFileName(String, RDFFormat) */ public static Optional<RDFFormat> getParserFormatForFileName(String fileName) { return RDFFormat.matchFileName(fileName, RDFParserRegistry.getInstance().getKeys()); }
/** * Tries to match a MIME type against the list of RDF formats that can be parsed. * * @param mimeType * A MIME type, e.g. "application/rdf+xml". * @return An RDFFormat object if a match was found, or {@link Optional#empty()} otherwise. * @see #getParserFormatForMIMEType(String, RDFFormat) */ public static Optional<RDFFormat> getParserFormatForMIMEType(String mimeType) { return RDFFormat.matchMIMEType(mimeType, RDFParserRegistry.getInstance().getKeys()); }
public Rdf4jIoFactory() { RDFParserRegistry.getInstance().add(new NquadsUdParserFactory()); }
/** * 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 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(); }
public static void assertRDFFilesIsomorphic(File expected, File actual, RDFFormat format) throws Exception { final RDFFormat expectedFormat; final RDFFormat actualFormat; if (format == null) { final RDFParserRegistry registry = RDFParserRegistry.getInstance(); expectedFormat = registry.getFileFormatForFileName(expected.getName()).orElse(null); actualFormat = registry.getFileFormatForFileName(actual.getName()).orElse(null); assertNotNull("Can't guess the expected file format", expectedFormat); assertNotNull("Can't guess the actual file format", actualFormat); } else { expectedFormat = format; actualFormat = format; } final Model expectedModel; final Model actualModel; try (final InputStream expectedStream = new FileInputStream(expected); final InputStream actualStream = new FileInputStream(actual)) { expectedModel = Rio.parse(expectedStream, "base://", expectedFormat); actualModel = Rio.parse(actualStream, "base://", actualFormat); } assertTrue("RDF files are not isomorphic", Models.isomorphic(expectedModel, actualModel)); }