encode method
- RdfGraph graph, {
- String? contentType,
- String? baseUri,
- RdfGraphEncoderOptions? options,
Encode an RDF graph to a string representation
Converts an in-memory RDF graph into a serialized string representation in the specified format. If no format is specified, the default codec (typically Turtle) is used.
The graph
parameter is the RDF graph to encode.
The contentType
parameter is an optional MIME type to specify the output format.
The baseUri
parameter is an optional base URI for the serialized output, which may enable
more compact representations with relative URIs.
The options
parameter contains optional format-specific encoder options (e.g., TurtleEncoderOptions).
Returns a string containing the serialized RDF data.
Throws CodecNotSupportedException if the requested codec is not supported. Throws codec-specific exceptions for serialization errors.
Implementation
String encode(
RdfGraph graph, {
String? contentType,
String? baseUri,
RdfGraphEncoderOptions? options,
}) => codec(
contentType: contentType,
encoderOptions: options,
).encode(graph, baseUri: baseUri);