TurtleCodec class final

RDF Codec implementation for the Turtle serialization format.

Turtle (Terse RDF Triple Language) is a textual syntax for RDF that is both readable by humans and parsable by machines. It is a simplified, compatible subset of the Notation3 (N3) format.

Turtle Syntax Overview

Turtle has several key features that make it popular for RDF serialization:

  • Prefixed names: Allow abbreviation of IRIs using prefixes

    @prefix foaf: <http://xmlns.com/foaf/0.1/> .
    <http://example.org/john> foaf:name "John Smith" .
    
  • Lists: Compact representation of ordered collections

    <http://example.org/list> <http://example.org/property> (1 2 3) .
    
  • Predicate lists: Group multiple predicates for the same subject

    <http://example.org/john> foaf:name "John Smith" ;
                              foaf:age 25 ;
                              foaf:mbox <mailto:john@example.org> .
    
  • Object lists: Group multiple objects for the same subject-predicate pair

    <http://example.org/john> foaf:nick "Johnny", "J", "JJ" .
    
  • Blank nodes: Represent anonymous resources

    <http://example.org/john> foaf:knows [ foaf:name "Jane" ] .
    

File Extension and MIME Types

Turtle files typically use the .ttl file extension. The primary MIME type is text/turtle.

Inheritance

Constructors

TurtleCodec({RdfNamespaceMappings? namespaceMappings, TurtleEncoderOptions encoderOptions = const TurtleEncoderOptions(), TurtleDecoderOptions decoderOptions = const TurtleDecoderOptions()})
Creates a new Turtle codec
const

Properties

decoder RdfGraphDecoder
Returns a Turtle decoder instance
no setteroverride
encoder RdfGraphEncoder
Returns a Turtle encoder instance
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
inverted Codec<String, RdfGraph>
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 Turtle codec
no setteroverride

Methods

canParse(String content) bool
Determines if the content is likely in Turtle format
override
decode(String input, {String? documentUrl, RdfGraphDecoderOptions? options}) RdfGraph
Decodes a string containing RDF data into an RDF graph
inherited
encode(RdfGraph 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<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}) TurtleCodec
Creates a new instance with the specified options
override

Operators

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