RDF.ex v0.6.1 RDF.Datatype behaviour View Source
A behaviour for natively supported literal datatypes.
A RDF.Datatype
implements the foundational functions for the lexical form,
the validation, conversion and canonicalization of typed RDF.Literal
s.
Link to this section Summary
Functions
Returns the RDF.Datatype
for a directly datatype IRI or the datatype IRI of a RDF.Literal
.
The IRIs of all datatypes with a RDF.Datatype
defined.
The mapping of IRIs of datatypes to their RDF.Datatype
.
All defined RDF.Datatype
modules.
Callbacks
Produces the canonical form of a RDF.Literal
.
Produces the lexical form of a value.
Casts a literal of another datatype into a literal of the datatype the function is implemented on.
Compares two RDF.Literal
s.
Converts a value into a proper native value.
Checks if the value of two RDF.Literal
s of this datatype are equal.
The IRI of the datatype.
Produces the lexical form of an invalid value of a typed Literal.
Produces the lexical form of a RDF.Literal
.
Determines if the value of a RDF.Literal
is a member of lexical value space of its datatype.
Link to this section Functions
get(id) View Source
Returns the RDF.Datatype
for a directly datatype IRI or the datatype IRI of a RDF.Literal
.
The IRIs of all datatypes with a RDF.Datatype
defined.
mapping() View Source
The mapping of IRIs of datatypes to their RDF.Datatype
.
modules() View Source
All defined RDF.Datatype
modules.
Link to this section Callbacks
canonical(arg1)
View Source
canonical(RDF.Literal.t()) :: RDF.Literal.t()
canonical(RDF.Literal.t()) :: RDF.Literal.t()
Produces the canonical form of a RDF.Literal
.
canonical_lexical(any) View Source
Produces the lexical form of a value.
cast(arg1)
View Source
cast(RDF.Literal.t()) :: RDF.Literal.t()
cast(RDF.Literal.t()) :: RDF.Literal.t()
Casts a literal of another datatype into a literal of the datatype the function is implemented on.
If the given literal is invalid or can not be converted into this datatype
nil
is returned.
compare(literal1, literal2)
View Source
compare(literal1 :: RDF.Literal.t(), literal2 :: RDF.Literal.t()) ::
:lt | :gt | :eq | :indeterminate | nil
compare(literal1 :: RDF.Literal.t(), literal2 :: RDF.Literal.t()) :: :lt | :gt | :eq | :indeterminate | nil
Compares two RDF.Literal
s.
Returns :gt
if first literal is greater than the second in terms of their datatype
and :lt
for vice versa. If the two literals are equal :eq
is returned.
For datatypes with only partial ordering :indeterminate
is returned when the
order of the given literals is not defined.
Returns nil
when the given arguments are not comparable datatypes or if one
them is invalid.
The default implementation of the _using__
macro compares the values of the
canonical/1
forms of the given literals of this datatype.
convert(any, keyword) View Source
Converts a value into a proper native value.
If an invalid value is given an implementation should call super
, which
by default currently just returns nil
.
Note: If a value is valid is determined by the lexical space of the implemented
datatype, not by the Elixir semantics. For example, although 42
is a falsy value according to the Elixir semantics, this is not an element
of the lexical value space of an xsd:boolean
, so the RDF.Boolean
implementation of this datatype calls super
.
equal_value?(literal1, literal2)
View Source
equal_value?(literal1 :: RDF.Literal.t(), literal2 :: RDF.Literal.t()) ::
boolean() | nil
equal_value?(literal1 :: RDF.Literal.t(), literal2 :: RDF.Literal.t()) :: boolean() | nil
Checks if the value of two RDF.Literal
s of this datatype are equal.
Non-RDF terms are tried to be coerced via RDF.Term.coerce/1
before comparison.
Returns nil
when the given arguments are not comparable as literals of this datatype.
The default implementation of the _using__
macro compares the values of the
canonical/1
forms of the given literals of this datatype.
id()
View Source
id() :: RDF.IRI.t()
id() :: RDF.IRI.t()
The IRI of the datatype.
invalid_lexical(any) View Source
Produces the lexical form of an invalid value of a typed Literal.
The default implementation of the _using__
macro just returns to_string
representation of the value.
lexical(literal)
View Source
lexical(literal :: RDF.Literal.t()) :: any()
lexical(literal :: RDF.Literal.t()) :: any()
Produces the lexical form of a RDF.Literal
.
valid?(literal)
View Source
valid?(literal :: RDF.Literal.t()) :: boolean()
valid?(literal :: RDF.Literal.t()) :: boolean()
Determines if the value of a RDF.Literal
is a member of lexical value space of its datatype.