TriGCodec class final

RDF Codec implementation for the TriG serialization format.

TriG is an extension of Turtle that adds support for named graphs, allowing multiple RDF graphs to be represented in a single document. It is both readable by humans and parsable by machines.

TriG Syntax Overview

TriG supports all Turtle features plus named graphs:

  • All Turtle features: Prefixed names, lists, predicate lists, object lists, blank nodes

  • Named graphs with GRAPH keyword:

    @prefix ex: <http://example.org/> .
    GRAPH ex:graph1 {
      ex:subject ex:predicate "object" .
    }
    
  • Named graph shorthand:

    ex:graph1 {
      ex:subject ex:predicate "object" .
    }
    
  • Default graph: Triples outside graph blocks

    ex:subject ex:predicate "object" .
    
  • Blank node graph names:

    _:graph1 {
      ex:subject ex:predicate "object" .
    }
    

File Extension and MIME Types

TriG files typically use the .trig file extension. The primary MIME type is application/trig.

Inheritance

Constructors

TriGCodec({RdfNamespaceMappings? namespaceMappings, TriGEncoderOptions encoderOptions = const TriGEncoderOptions(), TriGDecoderOptions decoderOptions = const TriGDecoderOptions(), IriTermFactory iriTermFactory = IriTerm.validated})
Creates a new TriG codec
const

Properties

decoder RdfDatasetDecoder
Returns a TriG decoder instance
no setteroverride
encoder RdfDatasetEncoder
Returns a TriG encoder instance
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
inverted Codec<String, RdfDataset>
Inverts this.
no setterinherited
primaryMimeType String
Returns the primary MIME type for Turtle format
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
supportedMimeTypes Set<String>
Returns all MIME types supported by this TriG codec
no setteroverride

Methods

canParse(String content) bool
Determines if the content is likely in TriG format
override
decode(String input, {String? documentUrl, RdfGraphDecoderOptions? options}) RdfDataset
Decodes a string containing RDF data into an RDF graph
inherited
encode(RdfDataset input, {String? baseUri, RdfGraphEncoderOptions? options}) String
Encodes an RDF graph to a string representation in this codec
inherited
fuse<R>(Codec<String, R> other) Codec<RdfDataset, 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, IriTermFactory? iriTermFactory}) TriGCodec
Creates a new instance with the specified options
override

Operators

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