|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.deri.iris.builtins.BuiltinHelper
public class BuiltinHelper
Some helper methods common to some Builtins.
| Field Summary | |
|---|---|
static ITuple |
EMPTY_TUPLE
Empty tuple (with arity 0) to avoid some timeconsuming creation of tuples. |
| Method Summary | |
|---|---|
static ITerm |
add(ITerm t0,
ITerm t1)
Produces the sum of two terms. |
static int |
compare(ITerm t0,
ITerm t1)
Compares two terms to each other. |
static int[] |
complement(int[] i,
int l)
Computes the complement of an index array. |
static ITerm[] |
concat(int[] idx0,
ITerm[] t0,
ITerm[] t1)
Concats two term arrays taking an index array into account. |
static ITerm |
dayPart(ITerm term)
|
static int[] |
determineGround(Collection<ITerm> t)
Determines the indexes of the ground terms in a collection. |
static int[] |
determineUnground(Collection<ITerm> t)
Determines the indexes of the unground terms in a collection. |
static ITerm |
divide(ITerm t0,
ITerm t1)
Produces the quotient of two terms. |
static ITerm[] |
getIndexes(Collection<ITerm> t,
int[] pos)
Returns the terms at a given position in a collection. |
static ITerm |
hourPart(ITerm term)
|
static ITerm |
minutePart(ITerm term)
|
static ITerm |
modulus(ITerm t0,
ITerm t1)
Produces the modulus of two terms. |
static ITerm |
monthPart(ITerm term)
|
static ITerm |
multiply(ITerm t0,
ITerm t1)
Produces the product of two terms. |
static int |
numbersCompare(INumericTerm n0,
INumericTerm n1)
Compares two numeric terms using the compareTo method of the
terms. |
static boolean |
numbersEqual(INumericTerm n0,
INumericTerm n1)
Compares two numerics by casting them to doubles and then comparing them for equality. |
static ITerm |
promote(ITerm t0,
ITerm t1)
Promotes a term from one type to another according to the promotion rules defined in the XPath specification: Numeric type promotion A value of type xs:float (or any type derived by restriction from xs:float) can be promoted to the type xs:double. |
static ITerm |
secondPart(ITerm term)
|
static ITerm |
subtract(ITerm t0,
ITerm t1)
Produces the difference of two terms. |
static ITerm |
timezonePart(ITerm term)
|
static ITerm |
yearPart(ITerm term)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final ITuple EMPTY_TUPLE
| Method Detail |
|---|
public static boolean numbersEqual(INumericTerm n0,
INumericTerm n1)
INumericTerm.
n0 - the first numbern1 - the second number
NullPointerException - if one of the numbers is nullNumber
public static int numbersCompare(INumericTerm n0,
INumericTerm n1)
compareTo method of the
terms. Respects floating point round off errors.
n0 - the first numbern1 - the second number
0 if they are equal, a value < 0 if
n0 is smaller than n1 and a value > 0 if n0 is
bigger than n1
NullPointerException - if one of the numbers is nullNumber
public static int compare(ITerm t0,
ITerm t1)
<0,
0 or >0 will be returned, if the first term
is smaller, equal or greater than the second one.
t0 - the first termt1 - the second term
NullPointerException - if one of the terms is null
IllegalArgumentException - if the two terms couldn't be compared
public static ITerm add(ITerm t0,
ITerm t1)
Produces the sum of two terms. The resulting term will be of the most accurate type of the submitted ones.
t0 - the first summandt1 - the second summand
NullPointerException - if one of the terms is null
IllegalArgumentException - if the operation couldn't be applied to
the terms
public static ITerm subtract(ITerm t0,
ITerm t1)
Produces the difference of two terms. The resulting term will be of the most accurate type of the submitted ones.
t0 - the minuendt1 - the subtrahend
NullPointerException - if one of the terms is null
IllegalArgumentException - if the operation couldn't be applied to
the terms
public static ITerm multiply(ITerm t0,
ITerm t1)
Produces the product of two terms. The resulting term will be of the most accurate type of the submitted ones.
At the moment only INumericTerms are supported.
t0 - the first factort1 - the second factor
NullPointerException - if one of the terms is null
IllegalArgumentException - if one of the terms is not a
INumericTerm
public static ITerm divide(ITerm t0,
ITerm t1)
throws EvaluationException
Produces the quotient of two terms. The resulting term will be of the most accurate type of the submitted ones.
At the moment only INumericTerms are supported.
t0 - the dividendt1 - the divisor
EvaluationException
NullPointerException - if one of the terms is null
public static ITerm modulus(ITerm t0,
ITerm t1)
throws EvaluationException
Produces the modulus of two terms. The resulting term will be of the most accurate type of the submitted ones.
At the moment only INumericTerms are supported.
t0 - the first argumentt1 - the second argument
EvaluationException
NullPointerException - if one of the terms is null
IllegalArgumentException - if one of the terms is not a
INumericTerm
public static ITerm promote(ITerm t0,
ITerm t1)
t0 - The term which should be promoted depending on the term
t1.t1 - The term according to which the term t0 is
promoted.
public static ITerm yearPart(ITerm term)
public static ITerm monthPart(ITerm term)
public static ITerm dayPart(ITerm term)
public static ITerm hourPart(ITerm term)
public static ITerm minutePart(ITerm term)
public static ITerm secondPart(ITerm term)
public static ITerm timezonePart(ITerm term)
public static int[] determineGround(Collection<ITerm> t)
t - the collection where to search for ground terms
NullPointerException - if the collection is null
public static ITerm[] getIndexes(Collection<ITerm> t,
int[] pos)
t - the collection from where to retrieve the termspos - the positions of the terms to retrieve
NullPointerException - if the collection is null
NullPointerException - if the position array is null
IllegalArgumentException - if ther are more terms requested, than
given (pos.length > t.size())public static int[] determineUnground(Collection<ITerm> t)
t - the collection where to search for ground terms
NullPointerException - if the collection is null
public static int[] complement(int[] i,
int l)
Computes the complement of an index array.
E.g. we have computed an index array [1, 3, 4] of a
collection with length 5 we would get [0, 2] as complement.
i - the array from which to compute the complementl - the length of the collection whe took the index from
NullPointerException - if the index array was null
IllegalArgumentException - if the lenght was nevative#determineGround(Collection) ,
#determineUnground(Collection)
public static ITerm[] concat(int[] idx0,
ITerm[] t0,
ITerm[] t1)
Concats two term arrays taking an index array into account.
E.g. we got an index of [0, 3, 4], the firs array is
['a', 'b', 'c'] and the second [12, 13, 14] we
will get ['a', 12, 13, 'b', 'c', 14].
idx0 - the index arrayt0 - the first array (this terms will be put at he positions of the
index array)t1 - the second array (with this terms the gaps will be filled up)
NullPointerException - if the index array is null
NullPointerException - if one of the term arrays is
null
IllegalArgumentException - if the lenght of the index and the first
term array don't match#determineGround(Collection) ,
#determineUnground(Collection)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||