codec method
- String? contentType,
- RdfGraphEncoderOptions? encoderOptions,
- RdfGraphDecoderOptions? decoderOptions,
Get a codec for a specific content type
Returns a codec that can handle the specified content type. If no content type is specified, returns the default codec (typically for Turtle).
The contentType
parameter is an optional MIME type to specify the format.
If not specified, then the encoding will be with the default codec (the first
codec registered, typically turtle) and the decoding codec will be automatically
detected.
The encoderOptions
parameter allows for format-specific encoder options.
The decoderOptions
parameter allows for format-specific decoder options.
Returns an RdfGraphCodec that can handle the specified content type.
Throws CodecNotSupportedException if the requested format is not supported.
Implementation
RdfGraphCodec codec({
String? contentType,
RdfGraphEncoderOptions? encoderOptions,
RdfGraphDecoderOptions? decoderOptions,
}) {
final codec = _registry.getGraphCodec(contentType);
if (encoderOptions != null || decoderOptions != null) {
return codec.withOptions(
encoder: encoderOptions,
decoder: decoderOptions,
);
}
return codec;
}