convert method
override
Encodes an RDF graph to a string representation in a specific format.
Transforms an in-memory RDF graph into an encoded text format that can be stored or transmitted. The exact output format depends on the implementing class.
Parameters:
graph
The RDF graph to encode.baseUri
Optional base URI for resolving/shortening IRIs in the output. When provided, the encoder may use this to produce more compact output.
Returns:
- The serialized representation of the graph as a string.
Implementation
@override
String convert(RdfGraph graph, {String? baseUri}) {
_logger.fine('Serializing graph to N-Triples');
// N-Triples ignores baseUri and customPrefixes as it doesn't support
// relative IRIs or prefixed names
final buffer = StringBuffer();
for (final triple in graph.triples) {
_writeTriple(buffer, triple);
buffer.writeln();
}
return buffer.toString();
}