RdfNamespaceMappings class

A class that provides access to RDF namespace mappings with support for custom mappings.

This immutable class provides RDF namespace prefix-to-URI mappings for common RDF vocabularies. It can be extended with custom mappings and supports the spread operator via the asMap method.

To use with the spread operator:

final mappings = {
  ...RdfNamespaceMappings().asMap(),
  'custom': 'http://example.org/custom#'
};

To create custom mappings:

final customMappings = RdfNamespaceMappings.custom({
  'ex': 'http://example.org/',
  'custom': 'http://example.org/custom#'
});

// Access a namespace URI by prefix
final exUri = customMappings['ex']; // http://example.org/

Constructors

RdfNamespaceMappings()
Creates a new RdfNamespaceMappings instance with standard mappings.
const
RdfNamespaceMappings.custom(Map<String, String> customMappings, {dynamic useDefaults = true})
Creates a new RdfNamespaceMappings instance with custom mappings.

Properties

hashCode int
The hash code for this object.
no setterinherited
length → dynamic
Returns the number of mappings in this instance.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

asMap() Map<String, String>
Creates an unmodifiable view of the underlying mappings.
containsKey(String prefix) bool
Checks if the mappings contain a specific prefix.
getOrGeneratePrefix(String namespace, {Map<String, String> customMappings = const {}}) → (String, bool)
Returns the Prefix for a given namespace URI, generating a new one if not found.
getPrefix(String namespace, {Map<String, String> customMappings = const {}}) String?
Returns the prefix for a given namespace URI.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited
operator [](Object? key) String?
Operator for retrieving a namespace URI by its prefix.

Static Methods

extractNamespaceAndLocalPart(String iri, {bool allowNumericLocalNames = true}) → (String, String)
Extracts the namespace and local part from an IRI