org.deri.iris.builtins.datatype
Class ConversionBuiltin
java.lang.Object
org.deri.iris.builtins.AbstractBuiltin
org.deri.iris.builtins.FunctionalBuiltin
org.deri.iris.builtins.datatype.ConversionBuiltin
- All Implemented Interfaces:
- Comparable<IAtom>, IAtom, IBuiltinAtom
- Direct Known Subclasses:
- ToBase64Builtin, ToBooleanBuiltin, ToDateBuiltin, ToDateTimeBuiltin, ToDayTimeDurationBuiltin, ToDecimalBuiltin, ToDoubleBuiltin, ToDurationBuiltin, ToFloatBuiltin, ToGDayBuiltin, ToGMonthBuiltin, ToGMonthDayBuiltin, ToGYearBuiltin, ToGYearMonthBuiltin, ToHexBinaryBuiltin, ToIntegerBuiltin, ToIriBuiltin, ToPlainLiteralBuiltin, ToStringBuiltin, ToTimeBuiltin, ToXMLLiteralBuiltin, ToYearMonthDurationBuiltin
public abstract class ConversionBuiltin
- extends FunctionalBuiltin
Represents a data type conversion function. Implementations of this built-in
convert supported data types to a specific data type.
|
Method Summary |
protected ITerm |
computeResult(ITerm[] terms)
Computes the result when all terms but the term at the last position are
known. |
protected abstract ITerm |
convert(ITerm term)
Converts the given supported data type instance to the specific data type |
ConversionBuiltin
protected ConversionBuiltin(IPredicate predicate,
ITerm... terms)
- Creates a new ConversionBuiltin instance. The number of terms submitted
to this constructor must match the arity of the predicate, which in this
case must always be two.
- Parameters:
predicate - The special predicate for this built-in.terms - The terms defining the values and variables for this
built-in.
- Throws:
NullPointerException - If the predicate or the terms is null.
NullPointerException - If the terms contain null.
IllegalArgumentException - If the length of the terms and the arity
of the predicate do not match.
computeResult
protected ITerm computeResult(ITerm[] terms)
- Description copied from class:
FunctionalBuiltin
- Computes the result when all terms but the term at the last position are
known.
- Specified by:
computeResult in class FunctionalBuiltin
- Parameters:
terms - The terms, where the terms at the last position is a
variable representing the result.
- Returns:
- The computed term, or
null if the operation is
unsuccessful.
convert
protected abstract ITerm convert(ITerm term)
- Converts the given supported data type instance to the specific data type
- Parameters:
terms - The term representing the data type to be converted.
- Returns:
- The result of the conversion or
null if the
specified data type is not compatible.
- Throws:
IllegalArgumentException - If the conversion fails for the
specified value.