encode method
- RdfGraph input, {
- String? baseUri,
- RdfGraphEncoderOptions? options,
override
Encodes an RDF graph to a string representation in this codec
This is a convenience method that delegates to the codec's encoder. It transforms an in-memory RDF graph into an encoded text representation that can be stored or transmitted.
The input
parameter is the RDF graph to encode.
The baseUri
parameter is an optional base URI for resolving/shortening IRIs in the output.
When provided, the encoder may use this to produce more compact output.
The options
parameter contains optional encoder options to use for this encoding operation.
Can include custom namespace prefixes and other encoder-specific settings.
Returns the serialized representation of the graph as a string.
Example:
final turtle = TurtleCodec();
final options = RdfGraphEncoderOptions(customPrefixes: {'ex': 'http://example.org/'});
final serialized = turtle.encode(graph, options: options);
Implementation
String encode(
RdfGraph input, {
String? baseUri,
RdfGraphEncoderOptions? options,
}) {
return (options == null ? encoder : encoder.withOptions(options)).convert(
input,
baseUri: baseUri,
);
}