RdfGraphCodec class abstract

Represents a content codec that can be handled by the RDF framework.

A codec plugin encapsulates all the logic needed to work with a specific RDF serialization format (like Turtle, JSON-LD, RDF/XML, etc.). It provides both decoding and encoding capabilities for the format.

To add support for a new RDF format, implement this interface and register an instance with the RdfCodecRegistry.

Example of implementing a new format:

class MyCustomGraphCodec implements RdfGraphCodec {
  @override
  String get primaryMimeType => 'application/x-custom-rdf';

  @override
  Set<String> get supportedMimeTypes => {primaryMimeType};

  @override
  RdfGraphDecoder get decoder => MyCustomGraphDecoder();

  @override
  RdfGraphEncoder get encoder => MyCustomGraphEncoder();

  @override
  bool canParse(String content) {
    // Check if the content appears to be in this format
    return content.contains('CUSTOM-RDF-FORMAT');
  }

  @override
  RdfGraphCodec withOptions({
    RdfGraphEncoderOptions? encoder,
    RdfGraphDecoderOptions? decoder,
  })  => this;
}
Inheritance
Implementers

Constructors

RdfGraphCodec()
Creates a new codec instance with default settings
const

Properties

decoder RdfGraphDecoder
Creates a decoder instance for this codec
no setteroverride
encoder RdfGraphEncoder
Creates an encoder instance for this codec
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
inverted Codec<String, RdfGraph>
Inverts this.
no setterinherited
primaryMimeType String
The primary MIME type for this codec
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
supportedMimeTypes Set<String>
All MIME types supported by this codec
no setter

Methods

canParse(String content) bool
Tests if the provided content is likely in this codec's format
decode(String input, {String? documentUrl, RdfGraphDecoderOptions? options}) RdfGraph
Decodes a string containing RDF data into an RDF graph
override
encode(RdfGraph input, {String? baseUri, RdfGraphEncoderOptions? options}) String
Encodes an RDF graph to a string representation in this codec
override
fuse<R>(Codec<String, R> other) Codec<RdfGraph, R>
Fuses this with other.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
withOptions({RdfGraphEncoderOptions? encoder, RdfGraphDecoderOptions? decoder}) RdfGraphCodec
Creates a new codec instance with the specified options

Operators

operator ==(Object other) bool
The equality operator.
inherited