@Override public Lang getLang() { return format.getLang() ; }
@Override public Lang getLang() { return format.getLang() ; }
@Override public Lang getLang() { return format.getLang() ; }
/** Is the RDFFormat registered for use? */ public static boolean contains(RDFFormat format) { return langToFormat.containsKey(format.getLang()) && (registryGraph.containsKey(format) || registryDataset.containsKey(format)); }
public NeedEvent(String uri, String wonNodeUri, TYPE eventType, long crawlDate, Dataset ds) { this.uri = uri; this.wonNodeUri = wonNodeUri; this.eventType = eventType; this.crawlDate = crawlDate; StringWriter sw = new StringWriter(); RDFDataMgr.write(sw, ds, RDFFormat.TRIG.getLang()); serializedNeedResource = sw.toString(); serializationLangName = RDFFormat.TRIG.getLang().getName(); serializationLangContentType = RDFFormat.TRIG.getLang().getContentType().getContentType(); }
public static Dataset toDataset(InputStream stream, RDFFormat rdfFormat) { Dataset dataset = DatasetFactory.createGeneral(); RDFDataMgr.read(dataset, stream, rdfFormat.getLang()); try { stream.close(); } catch (IOException ex) { logger.warn("An exception occurred.", ex); } return dataset; }
/** Set the output format for sending RDF Datasets to the remote server. * This is used for HTTP PUT and POST to a dataset. * This must be a quads format. */ public RDFConnectionRemoteBuilder quadsFormat(RDFFormat fmtQuads) { if ( ! RDFLanguages.isQuads(fmtQuads.getLang()) ) throw new RiotException("Not a language for RDF Datasets: "+fmtQuads); this.outputQuads = fmtQuads; return this; }
/** Set the output format for sending RDF graphs to the remote server. * This is used for the SPARQ Graph Store Protocol. */ public RDFConnectionRemoteBuilder triplesFormat(RDFFormat fmtTriples) { if ( ! RDFLanguages.isTriples(fmtTriples.getLang()) ) throw new RiotException("Not a language for RDF Graphs: "+fmtTriples); this.outputTriples = fmtTriples; return this; }
/** Set the output format for sending RDF Datasets to the remote server. * This is used for HTTP PUT and POST to a dataset. * This must be a quads format. */ public RDFConnectionRemoteBuilder quadsFormat(RDFFormat fmtQuads) { if ( ! RDFLanguages.isQuads(fmtQuads.getLang()) ) throw new RiotException("Not a language for RDF Datasets: "+fmtQuads); this.outputQuads = fmtQuads; return this; }
/** Set the output format for sending RDF graphs to the remote server. * This is used for the SPARQ Graph Store Protocol. */ public RDFConnectionRemoteBuilder triplesFormat(RDFFormat fmtTriples) { if ( ! RDFLanguages.isTriples(fmtTriples.getLang()) ) throw new RiotException("Not a language for RDF Graphs: "+fmtTriples); this.outputTriples = fmtTriples; return this; }
@Override public synchronized Dataset readNeedFromFile(final File file) throws IOException { logger.debug("processing as turtle file: {} ", file); try (FileInputStream fis = new FileInputStream(file)) { Dataset dataset = DatasetFactory.createGeneral(); RDFDataMgr.read(dataset, fis, RDFFormat.TRIG.getLang()); NeedModelWrapper needModelWrapper = new NeedModelWrapper(dataset); return needModelWrapper.copyDataset(); } catch (Exception e) { logger.error("could not parse trig from file {} ", file, e); throw e; } }
@Test public void writer10() { if ( format.getLang() != Lang.JSONLD ) // Fails in jsonld-java test("writer-rt-10.ttl") ; }
/** Create an HttpEntity for the graph */ protected HttpEntity graphToHttpEntity(Graph graph, RDFFormat syntax) { EntityTemplate entity = new EntityTemplate((out)->RDFDataMgr.write(out, graph, syntax)); String ct = syntax.getLang().getContentType().getContentType(); entity.setContentType(ct); return entity; }
/** Create an HttpEntity for the dataset */ protected HttpEntity datasetToHttpEntity(DatasetGraph dataset, RDFFormat syntax) { EntityTemplate entity = new EntityTemplate((out)->RDFDataMgr.write(out, dataset, syntax)); String ct = syntax.getLang().getContentType().getContentType(); entity.setContentType(ct); return entity; }
@Test public void writer09() { if ( format.getLang() != Lang.JSONLD ) // Fails in jsonld-java test("writer-rt-09.ttl") ; }
/** Create an HttpEntity for the dataset */ protected HttpEntity datasetToHttpEntity(DatasetGraph dataset, RDFFormat syntax) { EntityTemplate entity = new EntityTemplate((out)->RDFDataMgr.write(out, dataset, syntax)); String ct = syntax.getLang().getContentType().getContentType(); entity.setContentType(ct); return entity; }
/** Create an HttpEntity for the graph */ protected HttpEntity graphToHttpEntity(Graph graph, RDFFormat syntax) { EntityTemplate entity = new EntityTemplate((out)->RDFDataMgr.write(out, graph, syntax)); String ct = syntax.getLang().getContentType().getContentType(); entity.setContentType(ct); return entity; }
@Test public void writer08() { if ( format.getLang().equals(Lang.JSONLD) ) // Broken for JSON-LD (json-ld-java 0.5.0) return ; test("writer-rt-28.trig") ; } @Test public void writer09() { test("writer-rt-29.trig") ; }
/** Create an HttpEntity for the graph */ protected static HttpEntity graphToHttpEntity(final Graph graph) { final RDFFormat syntax = RDFFormat.TURTLE_BLOCKS ; ContentProducer producer = new ContentProducer() { @Override public void writeTo(OutputStream out) { RDFDataMgr.write(out, graph, syntax) ; } } ; EntityTemplate entity = new EntityTemplate(producer) ; ContentType ct = syntax.getLang().getContentType() ; entity.setContentType(ct.getContentType()) ; return entity ; }
/** Create an HttpEntity for the graph */ protected static HttpEntity graphToHttpEntity(final Graph graph) { final RDFFormat syntax = RDFFormat.TURTLE_BLOCKS ; ContentProducer producer = new ContentProducer() { @Override public void writeTo(OutputStream out) { RDFDataMgr.write(out, graph, syntax) ; } } ; EntityTemplate entity = new EntityTemplate(producer) ; ContentType ct = syntax.getLang().getContentType() ; entity.setContentType(ct.getContentType()) ; return entity ; } }