Public Member Functions | |
abstract Term | arg (int ano) |
abstract Term[] | args () |
int | arity () |
abstract String | debugString () |
double | doubleValue () |
float | floatValue () |
abstract boolean | hasFunctor (double value, int arity) |
abstract boolean | hasFunctor (int value, int arity) |
abstract boolean | hasFunctor (String name, int arity) |
int | intValue () |
boolean | isAtom () |
boolean | isCompound () |
boolean | isFloat () |
boolean | isInteger () |
boolean | isJFalse () |
boolean | isJNull () |
boolean | isJObject () |
boolean | isJRef () |
boolean | isJTrue () |
boolean | isJVoid () |
boolean | isVariable () |
abstract Object | jrefToObject () |
int | listLength () |
long | longValue () |
String | name () |
void | put (term_t term) |
Term | putParams (Term plist) |
Term | putParams (Term[] ps) |
Term[] | toTermArray () |
abstract int | type () |
abstract String | typeName () |
Static Public Member Functions | |
static String | debugString (Term arg[]) |
static Term | objectToJRef (Object obj) |
static void | putTerm (Object obj, term_t termref) |
static String | toString (Term[] args) |
Protected Member Functions | |
abstract void | getSubst (Map varnames_to_Terms, Map vars_to_Vars) |
abstract void | put (Map varnames_to_vars, term_t term) |
Term | putParams1 (IntHolder next, Term[] ps) |
Term () | |
Static Protected Member Functions | |
static void | getSubsts (Map varnames_to_Terms, Map vars_to_Vars, Term[] args) |
static Term | getTerm (term_t term) |
static Term | getTerm (Map vars_to_Vars, term_t term) |
static Term | getTerm1 (Map vars_to_Vars, term_t term) |
static Term[] | putParams2 (Term[] ts, IntHolder next, Term[] ps) |
static term_t | putTerms (Map varnames_to_vars, Term[] args) |
static boolean | terms_equals (Term[] t1, Term[] t2) |
Term is the abstract base class for Compound, Atom, Variable, Integer and Float, which comprise a Java-oriented concrete syntax for Prolog. You cannot create instances of Term directly; rather, you should create instances of Term's concrete subclasses. Alternatively, use textToTerm() to construct a Term from its conventional Prolog source text representation.
Copyright (C) 1998 Fred Dushin
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library Public License for more details.
Definition at line 67 of file Term.java.
jpl::Term::Term | ( | ) | [inline, protected] |
abstract Term jpl::Term::arg | ( | int | ano | ) | [pure virtual] |
returns the ano-th (1+) argument of a (Compound) Term throws a JPLException for any other subclass
Implemented in jpl::Compound, jpl::Float, jpl::Integer, jpl::JRef, and jpl::Variable.
abstract Term [] jpl::Term::args | ( | ) | [pure virtual] |
returns, as a Term[], the arguments of a Compound returns an empty Term[] from an Atom, Integer or Float throws a JPLException from a Variable
Implemented in jpl::Compound, jpl::Float, jpl::Integer, jpl::JRef, and jpl::Variable.
int jpl::Term::arity | ( | ) | [inline] |
returns, as an int, the arity of a Compound, Atom, Integer or Float throws a JPLException from a Variable
Reimplemented in jpl::Compound, jpl::Float, and jpl::Integer.
static String jpl::Term::debugString | ( | Term | arg[] | ) | [inline, static] |
Returns a debug-friendly representation of a list of Terms
abstract String jpl::Term::debugString | ( | ) | [pure virtual] |
Returns a debug-friendly representation of a Term
Implemented in jpl::Atom, jpl::Compound, jpl::Float, jpl::Integer, jpl::JRef, and jpl::Variable.
double jpl::Term::doubleValue | ( | ) | [inline] |
returns the value (as a double) of an Integer or Float throws a JPLException from any other subclass
Reimplemented in jpl::Float, and jpl::Integer.
float jpl::Term::floatValue | ( | ) | [inline] |
returns the value (as a float) of an Integer or Float throws a JPLException from a Compound, Atom or Variable
Reimplemented in jpl::Float, and jpl::Integer.
abstract void jpl::Term::getSubst | ( | Map | varnames_to_Terms, | |
Map | vars_to_Vars | |||
) | [protected, pure virtual] |
This method computes a substitution from a Term. The bindings Hashtable stores Terms, keyed by Variables. Thus, a substitution is as it is in mathematical logic, a sequence of the form = {t_0/x_0, ..., t_n/x_n}. Once the substitution is computed, the substitution should satisfy
T = t
where T is the Term from which the substitution is computed, and t is the term_t which results from the Prolog query.
A second Hashtable, vars, is required; this table holds the Variables that occur (thus far) in the unified term. The Variable instances in this table are guaranteed to be unique and are keyed on Strings which are Prolog internal representations of the variables.
bindings | table holding Term substitutions, keyed on Variables. | |
vars | A Hashtable holding the Variables that occur thus far in the term; keyed by internal (Prolog) string rep. |
Implemented in jpl::Compound, jpl::Float, jpl::Integer, jpl::JRef, and jpl::Variable.
static void jpl::Term::getSubsts | ( | Map | varnames_to_Terms, | |
Map | vars_to_Vars, | |||
Term[] | args | |||
) | [inline, static, protected] |
This method calls from_term_t on each term in the n consecutive term_ts. A temporary jpl.term_t "holder" (byref) structure must be created in order to extract type information from the Prolog engine.
vars_to_Vars | A Map from Prolog variables to jpl.Variable instances | |
n | The number of consecutive term_ts | |
term0 | The 0th term_t (structure); subsequent term_ts are not structures. |
vars | A Map from Prolog variables to jpl.Variable instances | |
term | The Prolog term (in a term_t holder) to convert |
Reimplemented in jpl::Atom, jpl::Compound, jpl::Float, jpl::Integer, and jpl::Variable.
abstract boolean jpl::Term::hasFunctor | ( | double | value, | |
int | arity | |||
) | [pure virtual] |
Tests whether this Term's functor has (double) 'name' and 'arity' Returns false if called inappropriately
Implemented in jpl::Compound, jpl::Float, jpl::Integer, jpl::JRef, and jpl::Variable.
abstract boolean jpl::Term::hasFunctor | ( | int | value, | |
int | arity | |||
) | [pure virtual] |
Tests whether this Term's functor has (int) 'name' and 'arity' Returns false if called inappropriately
Implemented in jpl::Compound, jpl::Float, jpl::Integer, jpl::JRef, and jpl::Variable.
abstract boolean jpl::Term::hasFunctor | ( | String | name, | |
int | arity | |||
) | [pure virtual] |
Tests whether this Term's functor has (String) 'name' and 'arity' Returns false if called inappropriately
Implemented in jpl::Compound, jpl::Float, jpl::Integer, jpl::JRef, and jpl::Variable.
int jpl::Term::intValue | ( | ) | [inline] |
returns the value (as an int) of an Integer or Float throws a JPLException from a Compound, Atom or Variable
Reimplemented in jpl::Float, and jpl::Integer.
boolean jpl::Term::isAtom | ( | ) | [inline] |
boolean jpl::Term::isCompound | ( | ) | [inline] |
boolean jpl::Term::isFloat | ( | ) | [inline] |
boolean jpl::Term::isInteger | ( | ) | [inline] |
boolean jpl::Term::isJFalse | ( | ) | [inline] |
whether this Term is a 'jfalse' structure, i.e. @(false)
Reimplemented in jpl::Compound.
boolean jpl::Term::isJNull | ( | ) | [inline] |
whether this Term is a 'jnull' structure, i.e. @(null)
Reimplemented in jpl::Compound.
boolean jpl::Term::isJObject | ( | ) | [inline] |
whether this Term is a 'jobject' structure, i.e. @(Tag)
Reimplemented in jpl::Compound.
boolean jpl::Term::isJRef | ( | ) | [inline] |
whether this Term is a 'jref' structure, i.e. @(Tag) or @(null)
Reimplemented in jpl::Compound.
boolean jpl::Term::isJTrue | ( | ) | [inline] |
whether this Term is a 'jtrue' structure, i.e. @(true)
Reimplemented in jpl::Compound.
boolean jpl::Term::isJVoid | ( | ) | [inline] |
whether this Term is a 'jvoid' structure, i.e. @(void)
Reimplemented in jpl::Compound.
boolean jpl::Term::isVariable | ( | ) | [inline] |
abstract Object jpl::Term::jrefToObject | ( | ) | [pure virtual] |
Implemented in jpl::Atom, jpl::Compound, jpl::Float, jpl::Integer, jpl::JRef, and jpl::Variable.
int jpl::Term::listLength | ( | ) | [inline] |
the length of this list, iff it is one, else an exception is thrown
JPLException |
long jpl::Term::longValue | ( | ) | [inline] |
returns the value (as a long) of an Integer or Float throws a JPLException from a Compound, Atom or Variable
Reimplemented in jpl::Float, and jpl::Integer.
String jpl::Term::name | ( | ) | [inline] |
returns, as a String, the name of a Compound, Atom or Variable throws a JPLException from an Integer or Float
Reimplemented in jpl::Compound, jpl::Float, jpl::Integer, and jpl::Variable.
static Term jpl::Term::objectToJRef | ( | Object | obj | ) | [inline, static] |
abstract void jpl::Term::put | ( | Map | varnames_to_vars, | |
term_t | term | |||
) | [protected, pure virtual] |
Cache the reference to the Prolog term_t here.
varnames_to_vars | A Map from variable names to JPL Variables. | |
term | A (previously created) term_t which is to be put with a Prolog term-type appropriate to the Term type (e.g., Atom, Variable, Compound, etc.) on which the method is invoked.) |
Implemented in jpl::Compound, jpl::Float, jpl::Integer, jpl::JRef, and jpl::Variable.
static void jpl::Term::putTerm | ( | Object | obj, | |
term_t | termref | |||
) | [inline, static] |
This static method converts an array of Terms to a *consecutive* sequence of term_t objects. Note that the first term_t object returned is a term_t class (structure); the succeeding term_t objects are consecutive references obtained by incrementing the *value* field of the term_t.
varnames_to_vars | Map from variable names to JPL Variables. | |
args | An array of jpl.Term references. |
This method is used (by Compound.equals) to determine the Terms in two Term arrays are pairwise equal, where two Terms are equal if they satisfy the equals predicate (defined differently in each Term subclass).
t1 | an array of Terms | |
t2 | another array of Terms |
static String jpl::Term::toString | ( | Term[] | args | ) | [inline, static] |
Term [] jpl::Term::toTermArray | ( | ) | [inline] |
returns an array of terms which are the successive members of this list, if it is a list, else throws an exception
JPLException |
abstract int jpl::Term::type | ( | ) | [pure virtual] |
returns the type of this term, as one of jpl.fli.Prolog.COMPOUND, .ATOM, .VARIABLE, .INTEGER, .FLOAT etc
Implemented in jpl::Atom, jpl::Compound, jpl::Float, jpl::Integer, jpl::JRef, and jpl::Variable.
abstract String jpl::Term::typeName | ( | ) | [pure virtual] |
returns the name of the type of this term, as one of "Compound", "Atom", "Variable", "Integer", "Float" etc
Implemented in jpl::Atom, jpl::Compound, jpl::Float, jpl::Integer, jpl::JRef, and jpl::Variable.