Package ai.chatur.cortex.core.jena
Class Rdf
java.lang.Object
ai.chatur.cortex.core.jena.Rdf
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 TypeMethodDescriptionstatic Stringwrite(org.apache.jena.query.Dataset dataset, org.apache.jena.riot.Lang lang) Serializes the dataset.static Stringwrite(org.apache.jena.rdf.model.Model model, org.apache.jena.riot.Lang lang) Serializes the model.static StringwriteReading(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 StringwriteReading(org.apache.jena.query.Dataset dataset, org.apache.jena.riot.Lang lang) Serializes the whole dataset, read in a read transaction.
-
Method Details
-
write
Serializes the model.- Parameters:
model- the model to serializelang- the syntax to serialize in- Returns:
- the model serialized in the given syntax
-
write
Serializes the dataset.- Parameters:
dataset- the dataset to serializelang- 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 frommodel- supplies the model to serialize, called inside the read transactionlang- 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 serializelang- the syntax to serialize in- Returns:
- the dataset serialized in the given syntax
-