use of org.apache.jena.riot.system.PrefixMap in project jena by apache.
the class ExJsonLD method write.
/**
* Write RDF data as JSON-LD.
*
* To get more control about the output,
* we have to use a mechanism provided by jena to pass information
* to the writing process (cf. org.apache.jena.riot.WriterDatasetRIOT and the "Context" mechanism).
* For that, we have to create a WriterDatasetRIOT (a one-time use object)
* and we pass a "Context" object (not to be confused with the "@context" in JSON-LD) as argument to its write method
*
* @param out
* @param f RDFFormat of the output, eg. RDFFormat.JSONLD_COMPACT_PRETTY
* @param g the data that we want to output as JSON-LD
* @param ctx the object that allows to control the writing process (a set of parameters)
*/
void write(OutputStream out, DatasetGraph g, RDFFormat f, Context ctx) {
// create a WriterDatasetRIOT with the RDFFormat
WriterDatasetRIOT w = RDFDataMgr.createDatasetWriter(f);
PrefixMap pm = RiotLib.prefixMap(g);
String base = null;
w.write(out, g, pm, base, ctx);
}
use of org.apache.jena.riot.system.PrefixMap in project jena by apache.
the class BinRDF method protocolToStream.
/**
* Decode the contents of the TProtocol and send to the {@link StreamRDF}.
* @param protocol TProtocol
* @param dest Sink
*/
public static void protocolToStream(TProtocol protocol, StreamRDF dest) {
PrefixMap pmap = PrefixMapFactory.create();
final Thrift2StreamRDF s = new Thrift2StreamRDF(pmap, dest);
dest.start();
// ** Java8
//apply(protocol, z -> TRDF.visit(z, s)) ;
applyVisitor(protocol, s);
dest.finish();
// No need to flush - we read from the protocol ;
}
use of org.apache.jena.riot.system.PrefixMap in project jena by apache.
the class TestPrefixLib method expand_2.
@Test
public void expand_2() {
PrefixMap prefixes = create();
prefixes.add(pref1, "http://example.net/ns#");
String x2 = PrefixLib.expand(prefixes, "pref1z:abc");
assertNull(x2);
}
use of org.apache.jena.riot.system.PrefixMap in project jena by apache.
the class TestPrefixLib method abbrev_2.
@Test
public void abbrev_2() {
PrefixMap prefixes = create();
prefixes.add(pref1, "http://example.net/ns#");
Pair<String, String> x = PrefixLib.abbrev(prefixes, "http://other/ns#xyz");
assertNull(x);
}
use of org.apache.jena.riot.system.PrefixMap in project jena by apache.
the class TestPrefixLib method expand_1.
@Test
public void expand_1() {
PrefixMap prefixes = create();
prefixes.add(pref1, "http://example.net/ns#");
String x = PrefixLib.expand(prefixes, "pref1:abc");
assertEquals("http://example.net/ns#abc", x);
String x2 = PrefixLib.expand(prefixes, "pref1z:abc");
assertNull(x2);
}
Aggregations