RdfCore.withStandardCodecs constructor

RdfCore.withStandardCodecs({
  1. RdfNamespaceMappings? namespaceMappings,
  2. List<RdfGraphCodec> additionalCodecs = const [],
})

Creates a new RDF library instance with standard codecs registered

This convenience constructor sets up an RDF library with Turtle, JSON-LD and N-Triples codecs ready to use. It's the recommended way to create an instance for most applications.

The namespaceMappings parameter provides optional custom namespace mappings for all codecs.

The additionalCodecs parameter is an optional list of additional codecs to register beyond the standard ones.

Example:

final rdf = RdfCore.withStandardCodecs();
final graph = rdf.decode(turtleData, contentType: 'text/turtle');

Implementation

factory RdfCore.withStandardCodecs({
  RdfNamespaceMappings? namespaceMappings,
  List<RdfGraphCodec> additionalCodecs = const [],
}) {
  final registry = RdfCodecRegistry();
  final _namespaceMappings =
      namespaceMappings ?? const RdfNamespaceMappings();

  // Register standard formats
  registry.registerGraphCodec(
    TurtleCodec(namespaceMappings: _namespaceMappings),
  );
  registry.registerGraphCodec(
    JsonLdGraphCodec(namespaceMappings: _namespaceMappings),
  );
  registry.registerGraphCodec(const NTriplesCodec());

  // Register additional codecs
  for (final codec in additionalCodecs) {
    registry.registerGraphCodec(codec);
  }

  return RdfCore(registry: registry);
}