Class Rdf

java.lang.Object
ai.chatur.cortex.core.jena.Rdf

public final class Rdf extends Object
Serializes a Model or Dataset to a string.

Every method writes to an in-memory StringWriter, whose close() is a no-op — unlike an actual I/O writer, serializing here can never throw a checked exception, so none of these methods declare one.

  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    write(org.apache.jena.query.Dataset dataset, org.apache.jena.riot.Lang lang)
    Serializes the dataset.
    static String
    write(org.apache.jena.rdf.model.Model model, org.apache.jena.riot.Lang lang)
    Serializes the model.
    static String
    writeReading(org.apache.jena.query.Dataset dataset, Supplier<org.apache.jena.rdf.model.Model> model, org.apache.jena.riot.Lang lang)
    Serializes the model, read in a read transaction on the dataset.
    static String
    writeReading(org.apache.jena.query.Dataset dataset, org.apache.jena.riot.Lang lang)
    Serializes the whole dataset, read in a read transaction.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • write

      public static String write(org.apache.jena.rdf.model.Model model, org.apache.jena.riot.Lang lang)
      Serializes the model.
      Parameters:
      model - the model to serialize
      lang - the syntax to serialize in
      Returns:
      the model serialized in the given syntax
    • write

      public static String write(org.apache.jena.query.Dataset dataset, org.apache.jena.riot.Lang lang)
      Serializes the dataset.
      Parameters:
      dataset - the dataset to serialize
      lang - the syntax to serialize in
      Returns:
      the dataset serialized in the given syntax
    • writeReading

      public static String writeReading(org.apache.jena.query.Dataset dataset, Supplier<org.apache.jena.rdf.model.Model> model, org.apache.jena.riot.Lang lang)
      Serializes the model, read in a read transaction on the dataset.

      Use this when the model to serialize is drawn from a transactional dataset — for example a named graph within it — so the read and the serialization happen under the same transaction.

      Parameters:
      dataset - the dataset the model is read from
      model - supplies the model to serialize, called inside the read transaction
      lang - the syntax to serialize in
      Returns:
      the model serialized in the given syntax
    • writeReading

      public static String writeReading(org.apache.jena.query.Dataset dataset, org.apache.jena.riot.Lang lang)
      Serializes the whole dataset, read in a read transaction.
      Parameters:
      dataset - the dataset to serialize
      lang - the syntax to serialize in
      Returns:
      the dataset serialized in the given syntax