public class JsonLDWriter extends WriterDatasetRIOTBase
WriterDatasetRIOT.write(OutputStream out, DatasetGraph datasetGraph, PrefixMap prefixMap, String baseURI, Context context)
)
with:
Context jenaContext = new Context() jenaCtx.set(JsonLDWriter.JSONLD_CONTEXT, contextAsJsonString);where contextAsJsonString is a JSON string containing the value of the "@context". It is possible to change the content of the "@context" node in the output using the
JSONLD_CONTEXT_SUBSTITUTION
Symbol.
For a frame output, one must pass a frame in the jenaContext using the JSONLD_FRAME
Symbol.
It is also possible to define the different options supported
by JSONLD-java using the JSONLD_OPTIONS
Symbol
The JsonLDWriteContext
is a convenience class that extends Context and
provides methods to set the values of these different Symbols that are used in controlling the writing of JSON-LD.
Note that this class also provides a static method to convert jena RDF data to the corresponding object in JsonLD API:
toJsonLDJavaAPI(org.apache.jena.riot.RDFFormat.JSONLDVariant, DatasetGraph, PrefixMap, String, Context)
Modifier and Type | Field and Description |
---|---|
static Symbol |
JSONLD_ADD_ALL_PREFIXES_TO_CONTEXT
if creating a (jsonld) context from dataset, should we include all the prefixes defined in graph's prefix mappings
value: a Boolean (default: true)
|
static Symbol |
JSONLD_CONTEXT
Expected value: the value of the "@context"
(a JSON String, or the object expected by the JSONLD-java API)
|
static Symbol |
JSONLD_CONTEXT_SUBSTITUTION
Expected value: the value of the "@context" to be put in final output (a JSON String)
This is NOT the context used to produce the output (given by JSONLD_CONTEXT,
or computed from the input RDF.
|
static Symbol |
JSONLD_FRAME
value: a JSON String, or the frame object expected by JsonLdProcessor.frame
|
static Symbol |
JSONLD_OPTIONS
value: the option object expected by JsonLdProcessor (instance of JsonLdOptions)
|
Constructor and Description |
---|
JsonLDWriter(RDFFormat syntaxForm) |
Modifier and Type | Method and Description |
---|---|
Lang |
getLang() |
static Object |
toJsonLDJavaAPI(RDFFormat.JSONLDVariant variant,
DatasetGraph dataset,
PrefixMap prefixMap,
String baseURI,
Context jenaContext)
the JsonLD-java API object corresponding to a dataset and a JsonLD format.
|
void |
write(OutputStream out,
DatasetGraph dataset,
PrefixMap prefixMap,
String baseURI,
Context context) |
void |
write(Writer out,
DatasetGraph dataset,
PrefixMap prefixMap,
String baseURI,
Context context)
Use of Writer is discouraged - let the serializer manage character sets in accordance with the format
|
public static final Symbol JSONLD_CONTEXT
public static final Symbol JSONLD_CONTEXT_SUBSTITUTION
public static final Symbol JSONLD_FRAME
public static final Symbol JSONLD_OPTIONS
public static final Symbol JSONLD_ADD_ALL_PREFIXES_TO_CONTEXT
public JsonLDWriter(RDFFormat syntaxForm)
public Lang getLang()
public void write(Writer out, DatasetGraph dataset, PrefixMap prefixMap, String baseURI, Context context)
WriterDatasetRIOT
write
in interface WriterDatasetRIOT
write
in class WriterDatasetRIOTBase
out
- Writerdataset
- DatasetGraph to be writtenprefixMap
- PrefixMap - maybe null (default should be to use the prefixmapping from the Graph)baseURI
- base URI - may be null for "none"context
- Context (see specific implementation for details)public void write(OutputStream out, DatasetGraph dataset, PrefixMap prefixMap, String baseURI, Context context)
write
in interface WriterDatasetRIOT
write
in class WriterDatasetRIOTBase
out
- OutputStreamdataset
- DatasetGraph to be writtenprefixMap
- PrefixMap - maybe null (default should be to use the prefixmapping from the Graph)baseURI
- base URI - may be null for "none"context
- Context (see specific implementation for details)public static Object toJsonLDJavaAPI(RDFFormat.JSONLDVariant variant, DatasetGraph dataset, PrefixMap prefixMap, String baseURI, Context jenaContext) throws com.github.jsonldjava.core.JsonLdError, com.fasterxml.jackson.core.JsonParseException, IOException
com.github.jsonldjava.core.JsonLdError
com.fasterxml.jackson.core.JsonParseException
IOException
Licenced under the Apache License, Version 2.0