public static RDFWriter createWriter(Format format, OutputStream out) { return createWriter(format, out, Namespaces.DEFAULT); }
public static boolean isNameStartChar(int c) { return c == '_' || isPrefixStartChar(c); }
@Override protected void appendPredicate(UID uid) { append(uid); }
@Test public void OpenStream_with_Resource() throws IOException { assertTrue(new RDFSource("classpath:/test.ttl", Format.TURTLE, "test:context").openStream() != null); assertTrue(new RDFSource("file:src/test/resources/test.ttl", Format.TURTLE, "test:context").openStream() != null); assertTrue(new RDFSource("classpath:/tes.ttl", Format.TURTLE, "test:context").openStream() == null); }
public static RDFWriter createWriter(Format format, Writer writer, Map<String, String> prefixes) { if (format == Format.N3 || format == Format.TURTLE) { return new TurtleWriter(writer, prefixes); } else if (format == Format.NTRIPLES) { return new NTriplesWriter(writer); } else if (format == Format.RDFXML) { return new RDFXMLWriter(writer, prefixes); } else { throw new IllegalArgumentException("Unsupported format " + format); } }
protected void append(UID uid) throws IOException { if (uid.ln().length() == 0 || !TurtleUtil.isName(uid.ln())) { appendFull(uid); } else { appendPrefixed(uid); } }
public static String toString(LIT lit) { String value = "\"" + NTriplesUtil.escapeString(lit.getValue()) + "\""; if (lit.getLang() != null) { return value + "@" + LocaleUtil.toLang(lit.getLang()); } else { return value + "^^" + toString(lit.getDatatype()); } }
public static boolean isName(String str) { if (isNameStartChar(str.charAt(0))) { for (int i = 1; i < str.length(); i++) { if (!isNameChar(str.charAt(i))) { return false; } } return true; } else { return false; } }
protected void appendPredicate(UID uid) throws IOException { if (uid.equals(RDF.type)) { appendable.append("a"); } else { append(uid); } }
public static boolean isPrefixChar(int c) { return isNameChar(c); }
public static boolean isNameChar(int c) { return isNameStartChar(c) || Character.isDigit(c) || c == '-' || c == 0x00B7 || c >= 0x0300 && c <= 0x036F || c >= 0x203F && c <= 0x2040; }
public static String toString(UID uid) { return "<" + NTriplesUtil.escapeString(uid.getValue()) + ">"; }
public static RDFWriter createWriter(Format format, Writer writer) { return createWriter(format, writer, Namespaces.DEFAULT); }
@Override protected RDFWriter createWriter(Writer w) { return WriterUtils.createWriter(Format.NTRIPLES, w); }
@Override protected RDFWriter createWriter(Writer w) { return WriterUtils.createWriter(Format.TURTLE, w); }
public static RDFWriter createWriter(Format format, OutputStream out, Map<String, String> prefixes) { try { String encoding = format == Format.NTRIPLES ? "US-ASCII" : "UTF-8"; return createWriter(format, new OutputStreamWriter(out, encoding), prefixes); } catch (UnsupportedEncodingException e) { throw new IllegalStateException(e); } }
@Override protected RDFWriter createWriter(Writer w) { Map<String, String> prefixes = new HashMap<String, String>(Namespaces.DEFAULT); prefixes.put(DC.NS, "dc"); return WriterUtils.createWriter(Format.RDFXML, w, prefixes); }