RDF.PropertyMap (RDF.ex v0.9.1) View Source
A bidirectional mappings from atom names to RDF.IRI
s of properties.
These mapping can be used in all functions of the RDF data structures
to provide the meaning of the predicate terms in input statements or
define how the IRIs of predicates should be mapped with the value mapping
functions like RDF.Description.values/2
etc.
The :context
option of these functions either take a RDF.PropertyMap
directly
or anything from which a RDF.PropertyMap
can be created with new/1
.
Because the mapping is bidirectional each term and IRI can be used only in
one mapping of a RDF.PropertyMap
.
RDF.PropertyMap
implements the Enumerable
protocol and the Access
behaviour.
Link to this section Summary
Functions
Adds a set of property mappings to property_map
.
Adds a property mapping between term
and iri
to property_map
.
Adds a set of property mappings to property_map
and raises an error on conflicts.
Deletes the property mapping for term
from property_map
.
Drops the given terms
from the property_map
.
Returns the IRI for the given term
in property_map
.
Returns whether a mapping for the given term
is defined in property_map
.
Creates an empty RDF.PropertyMap
.
Creates a new RDF.PropertyMap
with initial mappings.
Adds a set of property mappings to property_map
overwriting all existing mappings.
Adds a property mapping between term
and iri
to property_map
overwriting existing mappings.
Returns the term for the given namespace
in prefix_map
.
Returns whether a mapping for the given iri
is defined in property_map
.
Link to this section Types
Link to this section Functions
Specs
Adds a set of property mappings to property_map
.
The mappings can be passed in various ways:
- as keyword lists or maps where terms for the RDF properties can
be given as atoms or strings, while the property IRIs can be given as
RDF.IRI
s or strings - a strict
RDF.Vocabulary.Namespace
from which all lowercased terms are added with their respective IRI; since IRIs can also be once in aRDF.PropertyMap
a defined alias term is preferred over an original term - another
RDF.PropertyMap
from which all mappings are merged
Unless a mapping for any of the terms or IRIs in the input
already exists,
an :ok
tuple is returned, otherwise an :error
tuple.
Specs
add(t(), coercible_term(), RDF.IRI.coercible()) :: {:ok, t()} | {:error, String.t()}
Adds a property mapping between term
and iri
to property_map
.
Unless another mapping for term
or iri
already exists, an :ok
tuple
is returned, otherwise an :error
tuple.
Specs
Adds a set of property mappings to property_map
and raises an error on conflicts.
See add/2
for the different forms in which mappings can be provided.
Specs
delete(t(), coercible_term()) :: t()
Deletes the property mapping for term
from property_map
.
If no mapping for term
exists, property_map
is returned unchanged.
Specs
drop(t(), [coercible_term()]) :: t()
Drops the given terms
from the property_map
.
If terms
contains terms that are not in property_map
, they're simply ignored.
Specs
iri(t(), coercible_term()) :: RDF.IRI.t() | nil
Returns the IRI for the given term
in property_map
.
Returns nil
, when the given term
is not present in property_map
.
Specs
iri_defined?(t(), coercible_term()) :: boolean()
Returns whether a mapping for the given term
is defined in property_map
.
Specs
new() :: t()
Creates an empty RDF.PropertyMap
.
Specs
Creates a new RDF.PropertyMap
with initial mappings.
See add/2
for the different forms in which mappings can be provided.
Specs
Adds a set of property mappings to property_map
overwriting all existing mappings.
See add/2
for the different forms in which mappings can be provided.
Note, that not just all mappings with the used terms in the input mappings
are overwritten, but also all mappings with IRIs in the input mappings
Specs
put(t(), coercible_term(), RDF.IRI.coercible()) :: t()
Adds a property mapping between term
and iri
to property_map
overwriting existing mappings.
Specs
term(t(), RDF.IRI.coercible()) :: atom() | nil
Returns the term for the given namespace
in prefix_map
.
Returns nil
, when the given namespace
is not present in prefix_map
.
Specs
term_defined?(t(), RDF.IRI.coercible()) :: boolean()
Returns whether a mapping for the given iri
is defined in property_map
.