View Source RDF.XSD.Boolean (RDF.ex v2.0.0)
RDF.XSD.Datatype
for xsd:boolean
.
Summary
Functions
Produces the canonical representation of a RDF.Literal
of this datatype.
Determines if the lexical form of a RDF.Literal
of this datatype is the canonical form.
Returns the canonical lexical form of a RDF.Literal
of this datatype.
Casts a datatype literal of one type into a datatype literal of another type.
Compares two RDF.Literal
s.
Checks if the given literal has datatype this or a datatype that is derived of it.
Returns an Effective Boolean Value (EBV).
Alias for ebv/1
.
Checks if two datatype literals are equal in terms of the values of their value space.
Returns RDF.XSD.true
if the effective boolean value of the given argument is RDF.XSD.false
, or RDF.XSD.false
if it is RDF.XSD.true
.
Returns the lexical form of a RDF.Literal
of this datatype.
Returns the logical AND
of the effective boolean value of the given arguments.
Returns the logical OR
of the effective boolean value of the given arguments.
Creates a new RDF.Literal
with this datatype and the given value
.
Creates a new RDF.Literal
with this datatype and the given value
or fails when it is not valid.
Updates the value of a RDF.Literal
without changing everything else.
Determines if a RDF.Literal
of this or a derived datatype has a proper value of its value space.
Returns the value of a RDF.Literal
of this or a derived datatype.
Types
@type input_value() :: RDF.Literal.t() | valid_value() | number() | String.t() | any()
@type invalid_value() :: nil
@type t() :: %RDF.XSD.Boolean{ uncanonical_lexical: RDF.XSD.Datatype.uncanonical_lexical(), value: value() }
@type valid_value() :: boolean()
@type value() :: valid_value() | invalid_value()
Functions
Produces the canonical representation of a RDF.Literal
of this datatype.
Determines if the lexical form of a RDF.Literal
of this datatype is the canonical form.
Returns the canonical lexical form of a RDF.Literal
of this datatype.
@spec cast(RDF.Literal.Datatype.literal() | RDF.Term.t()) :: RDF.Literal.t() | nil
Casts a datatype literal of one type into a datatype literal of another type.
Returns nil
when the given arguments are not castable into this datatype or when the given argument is an
invalid literal.
Implementations define the casting for a given value with the RDF.Literal.Datatype.do_cast/1
callback.
@spec compare(RDF.Literal.t() | any(), RDF.Literal.t() | any()) :: RDF.Literal.Datatype.comparison_result() | :indeterminate | nil
Compares two RDF.Literal
s.
If the first literal is greater than the second :gt
is returned, if less than :lt
is returned.
If both literal are equal :eq
is returned.
If the literals can not be compared either nil
is returned, when they generally can be compared
due to their datatype, or :indeterminate
is returned, when the order of the given values is
not defined on only partially ordered datatypes.
Checks if the given literal has datatype this or a datatype that is derived of it.
@spec ebv(input_value()) :: RDF.Literal.t() | nil
Returns an Effective Boolean Value (EBV).
The Effective Boolean Value is an algorithm to coerce values to a RDF.XSD.Boolean
.
It is specified and used in the SPARQL query language and is based upon XPath's
fn:boolean
. Other than specified in these specs any value which can not be
converted into a boolean results in nil
.
see
@spec effective(input_value()) :: RDF.Literal.t() | nil
Alias for ebv/1
.
Checks if two datatype literals are equal in terms of the values of their value space.
Non-RDF.Literal
s are tried to be coerced via RDF.Literal.coerce/1
before comparison.
Returns nil
when the given arguments are not comparable as literals of this
datatype.
Invalid literals are only considered equal in this relation when both have the exact same datatype and the same attributes (lexical form, language etc.).
Implementations can customize this equivalence relation via the RDF.Literal.Datatype.do_equal_value_different_datatypes?/2
and RDF.Literal.Datatype.do_equal_value_different_datatypes?/2
callbacks.
@spec fn_not(input_value()) :: t() | nil
Returns RDF.XSD.true
if the effective boolean value of the given argument is RDF.XSD.false
, or RDF.XSD.false
if it is RDF.XSD.true
.
Otherwise, it returns nil
.
Examples
iex> RDF.XSD.Boolean.fn_not(RDF.XSD.true)
RDF.XSD.false
iex> RDF.XSD.Boolean.fn_not(RDF.XSD.false)
RDF.XSD.true
iex> RDF.XSD.Boolean.fn_not(true)
RDF.XSD.false
iex> RDF.XSD.Boolean.fn_not(false)
RDF.XSD.true
iex> RDF.XSD.Boolean.fn_not(42)
RDF.XSD.false
iex> RDF.XSD.Boolean.fn_not("")
RDF.XSD.true
iex> RDF.XSD.Boolean.fn_not(nil)
nil
Returns the lexical form of a RDF.Literal
of this datatype.
@spec logical_and(input_value(), input_value()) :: t() | nil
Returns the logical AND
of the effective boolean value of the given arguments.
It returns nil
if only one argument is nil
and the other argument is
RDF.XSD.true
and RDF.XSD.false
if the other argument is RDF.XSD.false
.
Examples
iex> RDF.XSD.Boolean.logical_and(RDF.XSD.true, RDF.XSD.true)
RDF.XSD.true
iex> RDF.XSD.Boolean.logical_and(RDF.XSD.true, RDF.XSD.false)
RDF.XSD.false
iex> RDF.XSD.Boolean.logical_and(RDF.XSD.true, nil)
nil
iex> RDF.XSD.Boolean.logical_and(nil, RDF.XSD.false)
RDF.XSD.false
iex> RDF.XSD.Boolean.logical_and(nil, nil)
nil
@spec logical_or(input_value(), input_value()) :: t() | nil
Returns the logical OR
of the effective boolean value of the given arguments.
It returns nil
if only one argument is nil
and the other argument is
RDF.XSD.false
and RDF.XSD.true
if the other argument is RDF.XSD.true
.
Examples
iex> RDF.XSD.Boolean.logical_or(RDF.XSD.true, RDF.XSD.false)
RDF.XSD.true
iex> RDF.XSD.Boolean.logical_or(RDF.XSD.false, RDF.XSD.false)
RDF.XSD.false
iex> RDF.XSD.Boolean.logical_or(RDF.XSD.true, nil)
RDF.XSD.true
iex> RDF.XSD.Boolean.logical_or(nil, RDF.XSD.false)
nil
iex> RDF.XSD.Boolean.logical_or(nil, nil)
nil
Creates a new RDF.Literal
with this datatype and the given value
.
Creates a new RDF.Literal
with this datatype and the given value
or fails when it is not valid.
Updates the value of a RDF.Literal
without changing everything else.
Determines if a RDF.Literal
of this or a derived datatype has a proper value of its value space.
Returns the value of a RDF.Literal
of this or a derived datatype.