Package org.projog.core.term
Class TermUtils
java.lang.Object
org.projog.core.term.TermUtils
Helper methods for performing common tasks on
Term instances.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertType(Term t, TermType type) static voidBacktracks allTerms in the specified array.static Numericstatic Term[]Returns copies of the specified {link Term}sgetAllVariablesInTerm(Term argument) Returns allVariables contained in the specified term.private static voidgetAllVariablesInTerm(Term argument, Set<Variable> variables) static StringgetAtomName(Term t) static booleantermsEqual(Term a, Term b) static intstatic longtoLong(ArithmeticOperators operators, Term t) Return the long value represented by the specified term.static booleanAttempts to unify all correspondingTerms in the specified arrays.
-
Field Details
-
EMPTY_ARRAY
-
-
Constructor Details
-
TermUtils
private TermUtils()Private constructor as all methods are static.
-
-
Method Details
-
copy
Returns copies of the specified {link Term}s- Parameters:
input-Terms to copy- Returns:
- copies of the specified {link Term}s
-
backtrack
Backtracks allTerms in the specified array.- Parameters:
terms-Terms to backtrack- See Also:
-
unify
Attempts to unify all correspondingTerms in the specified arrays.Note: If the attempt to unify the corresponding terms is unsuccessful only the terms in
queryArgswill get backtracked.- Parameters:
queryArgs- terms to unify withconsequentArgsconsequentArgs- terms to unify withqueryArgs- Returns:
trueif the attempt to unify all corresponding terms was successful
-
getAllVariablesInTerm
Returns allVariables contained in the specified term.- Parameters:
argument- the term to find variables for- Returns:
- all
Variables contained in the specified term.
-
getAllVariablesInTerm
-
castToNumeric
-
toInt
- Parameters:
t- the term representing aNumeric- Returns:
- the
intvalue represented byt - Throws:
ProjogException- if the specifiedTermcannot be represented as anint.
-
toLong
Return the long value represented by the specified term.- Parameters:
t- the term representing a long value- Returns:
- the
longvalue represented byt - Throws:
ProjogException- if the specifiedTermdoes not represent a term of typeTermType.INTEGER
-
getAtomName
-
assertType
-
termsEqual
-