/** * return the RDF syntax with the given MIME-type. * * @param mimeTypes the MIME-type of the syntax to find * @return the syntax or <code>null</code>, if none registered */ public static Syntax forMimeType(String mimeType) { for(Syntax x : SYNTAXES) { if(x.getMimeTypes().contains(mimeType)) return x; } return null; }
/** * @see java.lang.Object#toString() */ @Override public String toString() { return "RDF Syntax '" + this.name + "' MIME-type=" + this.getMimeType(); }
/** * list all available syntaxes. List is not modifyable. * * @return a Collection of available syntaxes * @deprecated Use #collection() instead */ @Deprecated public static List<Syntax> list() { return new ArrayList<Syntax>(collection()); }
public void readFrom(InputStream in, Syntax syntax, String baseURI) throws IOException, ModelRuntimeException { this.assertModel(); RDFFormat rdfformat = RDFFormat.forMIMEType(syntax.getMimeType()); if (rdfformat == null) { throw new ModelRuntimeException("unknown Syntax: " + syntax.toString()); } else { try { this.connection.add(in, baseURI, rdfformat); } catch (OpenRDFException e) { throw new ModelRuntimeException(e); } } }
/** * return the RDF syntax with the given name. * * @param name the name of the syntax to search * @return the syntax or <code>null</code>, if none registered */ public static Syntax forName(String name) { for(Syntax x : SYNTAXES) { if(x.getName().equals(name)) return x; } return null; }
/** * return the RDF syntax for the given filename by looking at its file * extension. * * @param fileName * a file name to determine the file extension * @return the syntax or <code>null</code>, if none registered */ public static Syntax forFileName(String fileName) { String fileExtension = fileName.substring(fileName.lastIndexOf('.')); for(Syntax x : SYNTAXES) { if(x.getFilenameExtensions().contains(fileExtension)) return x; } return null; }
@Override public void readFrom(InputStream in, Syntax syntax) throws IOException, ModelRuntimeException { this.assertModel(); RDFFormat rdfformat = RDFFormat.forMIMEType(syntax.getMimeType()); if (rdfformat == null) { throw new ModelRuntimeException("unknown Syntax: " + syntax.toString()); } else { try { this.connection.add(in, "", rdfformat); } catch (OpenRDFException e) { throw new ModelRuntimeException(e); } } }
public void readFrom(Reader reader, Syntax syntax, String baseURI) throws IOException, ModelRuntimeException { this.assertModel(); RDFFormat format = RDFFormat.forMIMEType(syntax.getMimeType()); if (format == null) { throw new ModelRuntimeException("unknown RDF syntax: " + syntax.toString()); } else { try { this.connection.add(reader, baseURI, format); } catch (OpenRDFException e) { throw new ModelRuntimeException(e); } } }
/** * Resolves an RDF2Go {@link Syntax} to an OpenRDF {@link RDFFormat}. * * @param syntax The RDF2Go Syntax to resolve. * @return A RDFFormat for the specified syntax. * @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 " + "support for " + syntax); }
/** * Resolves a RDF2Go Syntax to an OpenRDF RDFFormat. * * @param syntax * The RDF2Go Syntax to resolve. * @return A RDFFormat for the specified syntax. * @throws ModelRuntimeException * When the Syntax could not be resolved to a RDFFormat. */ public static RDFFormat getRDFFormat(Syntax syntax) throws ModelRuntimeException { String mimeType = syntax.getMimeType(); return RDFFormat.forMIMEType(mimeType); }
@Override public void readFrom(Reader reader, Syntax syntax) throws IOException, ModelRuntimeException { this.assertModel(); RDFFormat format = RDFFormat.forMIMEType(syntax.getMimeType()); if (format == null) { throw new ModelRuntimeException("unknown RDF syntax: " + syntax.toString()); } else { try { this.connection.add(reader, "", format); } catch (OpenRDFException e) { throw new ModelRuntimeException(e); } } }
/** * Resolves an RDF2Go {@Link Syntax} to a Jena {@link Lang}. * * @param syntax * The RDF2Go Syntax to resolve. * @return A {@link Lang} for the specified syntax. * @throws SyntaxNotSupportedException * When the Syntax could not be resolved to a {@link Lang}. */ public static Lang getJenaLang(Syntax syntax) throws SyntaxNotSupportedException { for (String mimeType : syntax.getMimeTypes()) { Lang lang = RDFLanguages.contentTypeToLang(mimeType); if (lang != null) { return lang; } } throw new SyntaxNotSupportedException("This version of Jena seems to have no " + "support for " + syntax); }
@Override public void readFrom(InputStream stream, Syntax syntax, String baseURI) throws IOException, ModelRuntimeException { RDFFormat format = RDFFormat.forMIMEType(syntax.getMimeType()); if (format == null) { throw new ModelRuntimeException("unknown syntax: " + syntax); } readFrom(stream, format, baseURI); }
@Override public void readFrom(Reader reader, Syntax syntax, String baseURI) throws ModelRuntimeException, IOException { RDFFormat format = RDFFormat.forMIMEType(syntax.getMimeType()); if (format == null) { throw new ModelRuntimeException("unknown syntax: " + syntax); } readFrom(reader, format, baseURI); }
@Override public void readFrom(InputStream stream, Syntax syntax) throws IOException, ModelRuntimeException { RDFFormat format = RDFFormat.forMIMEType(syntax.getMimeType()); if (format == null) { throw new ModelRuntimeException("unknown syntax: " + syntax); } readFrom(stream, format, ""); }
public void readFrom(Reader reader, Syntax syntax) throws IOException, ModelRuntimeException { RDFFormat format = RDFFormat.forMIMEType(syntax.getMimeType()); if (format == null) { throw new ModelRuntimeException("unknown syntax: " + format); } readFrom(reader, format, ""); }