Class JsonLD10Writer

java.lang.Object
org.apache.jena.riot.writer.WriterDatasetRIOTBase
org.apache.jena.riot.writer.JsonLD10Writer
All Implemented Interfaces:
WriterDatasetRIOT

@Deprecated public class JsonLD10Writer extends WriterDatasetRIOTBase
Deprecated.
Migrate to JSON-LD 1.1
Writer that prints out JSON-LD. By default, the output is "compact" (in JSON-LD terminology), and the JSON is "pretty" (using line breaks). One can choose another form using one of the dedicated RDFFormats (JSONLD_EXPAND_PRETTY, etc.). For formats using a context (that is, which have an "@context" node), (compact and expand), this automatically generates a default one. One can pass a jsonld context using the (jena) Context mechanism, defining a (jena) Context (sorry for this clash of "contexts"), (cf. last argument in 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)
  • Field Details

    • JSONLD_CONTEXT

      public static final Symbol JSONLD_CONTEXT
      Deprecated.
      Expected value: the value of the "@context" (a JSON String, or the object expected by the JSONLD-java API)
    • JSONLD_CONTEXT_SUBSTITUTION

      public static final Symbol JSONLD_CONTEXT_SUBSTITUTION
      Deprecated.
      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. It is something that will replace the @context content. This is useful
      1. for the cases you want to have a URI as value of @context, without having JSON-LD java to download it and
      2. as a trick to change the URIs in your result.
      Only for compact and flatten formats. Note that it is supposed to be a JSON String: to set the value of @context to a URI, the String must be quoted.
    • JSONLD_FRAME

      public static final Symbol JSONLD_FRAME
      Deprecated.
      value: a JSON String, or the frame object expected by JsonLdProcessor.frame
    • JSONLD_OPTIONS

      public static final Symbol JSONLD_OPTIONS
      Deprecated.
      value: the option object expected by JsonLdProcessor (instance of JsonLdOptions)
    • JSONLD_ADD_ALL_PREFIXES_TO_CONTEXT

      public static final Symbol JSONLD_ADD_ALL_PREFIXES_TO_CONTEXT
      Deprecated.
      if creating a (jsonld) context from dataset, should we include all the prefixes defined in graph's prefix mappings value: a Boolean (default: true)
  • Constructor Details

    • JsonLD10Writer

      public JsonLD10Writer(RDFFormat syntaxForm)
      Deprecated.
  • Method Details

    • getLang

      public Lang getLang()
      Deprecated.
    • write

      public void write(Writer out, DatasetGraph dataset, PrefixMap prefixMap, String baseURI, Context context)
      Deprecated.
      Description copied from interface: WriterDatasetRIOT
      Use of Writer is discouraged - let the serializer manage character sets in accordance with the format
      Specified by:
      write in interface WriterDatasetRIOT
      Specified by:
      write in class WriterDatasetRIOTBase
      Parameters:
      out - Writer
      dataset - DatasetGraph to be written
      prefixMap - PrefixMap - maybe null (default should be to use the prefix mapping from the Graph)
      baseURI - base URI - may be null for "none"
      context - Context (see specific implementation for details)
    • write

      public void write(OutputStream out, DatasetGraph dataset, PrefixMap prefixMap, String baseURI, Context context)
      Deprecated.
      Specified by:
      write in interface WriterDatasetRIOT
      Specified by:
      write in class WriterDatasetRIOTBase
      Parameters:
      out - OutputStream
      dataset - DatasetGraph to be written
      prefixMap - PrefixMap - maybe null (default should be to use the prefix mapping from the Graph)
      baseURI - base URI - may be null for "none"
      context - Context (see specific implementation for details)
    • toJsonLDJavaAPI

      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
      Deprecated.
      the JsonLD-java API object corresponding to a dataset and a JsonLD format.
      Throws:
      com.github.jsonldjava.core.JsonLdError
      com.fasterxml.jackson.core.JsonParseException
      IOException