Package org.apache.jena.riot.lang
Class JsonLDReader
- java.lang.Object
-
- org.apache.jena.riot.lang.JsonLDReader
-
- All Implemented Interfaces:
ReaderRIOT
public class JsonLDReader extends java.lang.Object implements ReaderRIOT
One can pass a jsonld context using the (jena) Context mechanism, defining a (jena) Context (sorry for this clash of "contexts"), (cf. last argument inReaderRIOT.read(InputStream in, String baseURI, ContentType ct, StreamRDF output, Context context)) with:Context jenaContext = new Context() jenaCtx.set(JsonLdReader.JSONLD_CONTEXT, contextAsJsonString);
where contextAsJsonString is a JSON string containing the value of the "@context". It is also possible to define the different options supported by JSONLD-java using theJSONLD_OPTIONSSymbol TheJsonLDReadContextis 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: it is possible to override jsonld's "@context" value by providing one, using aContext, and setting theJSONLD_CONTEXTSymbol's value to the data expected by JSON-LD java API (aMap).
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringBLANK_NODEstatic java.lang.StringIRIstatic SymbolJSONLD_CONTEXTSymbol to use to pass (in a Context object) the "@context" to be used when reading jsonld (overriding the actual @context in the jsonld) Expected value: the value of the "@context", as expected by the JSONLD-java API (a Map)static SymbolJSONLD_OPTIONSvalue: the option object expected by JsonLdProcessor (instance of JsonLdOptions)static java.lang.StringLITERAL
-
Constructor Summary
Constructors Constructor Description JsonLDReader(Lang lang, ParserProfile profile, ErrorHandler errorHandler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidread(java.io.InputStream in, java.lang.String baseURI, ContentType ct, StreamRDF output, Context context)Read from an InputStream and output RDF on the StreamRDF.voidread(java.io.Reader reader, java.lang.String baseURI, ContentType ct, StreamRDF output, Context context)Read from an InputStream and output RDF on the StreamRDF.
-
-
-
Field Detail
-
JSONLD_CONTEXT
public static final Symbol JSONLD_CONTEXT
Symbol to use to pass (in a Context object) the "@context" to be used when reading jsonld (overriding the actual @context in the jsonld) Expected value: the value of the "@context", as expected by the JSONLD-java API (a Map)
-
JSONLD_OPTIONS
public static final Symbol JSONLD_OPTIONS
value: the option object expected by JsonLdProcessor (instance of JsonLdOptions)
-
LITERAL
public static java.lang.String LITERAL
-
BLANK_NODE
public static java.lang.String BLANK_NODE
-
IRI
public static java.lang.String IRI
-
-
Constructor Detail
-
JsonLDReader
public JsonLDReader(Lang lang, ParserProfile profile, ErrorHandler errorHandler)
-
-
Method Detail
-
read
public void read(java.io.Reader reader, java.lang.String baseURI, ContentType ct, StreamRDF output, Context context)Description copied from interface:ReaderRIOTRead from an InputStream and output RDF on the StreamRDF.- Specified by:
readin interfaceReaderRIOT- Parameters:
reader- Reader. InputStreams are preferred because Reader do not allow RIOT to set the character set.baseURI- Base URI (or null)ct- Content-Type if available. Routing to the right parser will have already been done so this only useful to get addition Content-Type information or if this ReaderRIOT can handle multiple media types.output- Destination for the parser output.context- Environment settings.
-
read
public void read(java.io.InputStream in, java.lang.String baseURI, ContentType ct, StreamRDF output, Context context)Description copied from interface:ReaderRIOTRead from an InputStream and output RDF on the StreamRDF.- Specified by:
readin interfaceReaderRIOT- Parameters:
in- InputStreambaseURI- Base URI (or null)ct- Content-Type if available. Routing to the right parser will have already been done so this only useful to get addition Content-Type information or if this ReaderRIOT can handle multiple media types.output- Destination for the parser output.context- Environment settings.
-
-