jpl::Term Class Reference

Inheritance diagram for jpl::Term:
Inheritance graph
[legend]

List of all members.

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)

Detailed Description

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) 2004 Paul Singleton

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.


Author:
Fred Dushin <fadushin@syr.edu>
Version:
$Revision$

Definition at line 67 of file Term.java.


Constructor & Destructor Documentation

jpl::Term::Term (  )  [inline, protected]

This default constructor is provided in order for subclasses to be able to define their own default constructors.

Definition at line 80 of file Term.java.


Member Function Documentation

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

Returns:
the ano-th argument of a (Compound) Term

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

Returns:
the arguments of a Compound as a Term[

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

Returns:
the arity of a Compound, Atom, Integer or Float

Reimplemented in jpl::Compound, jpl::Float, and jpl::Integer.

Definition at line 143 of file Term.java.

static String jpl::Term::debugString ( Term  arg[]  )  [inline, static]

Returns a debug-friendly representation of a list of Terms

Returns:
a debug-friendly representation of a list of Terms
Deprecated:

Definition at line 407 of file Term.java.

abstract String jpl::Term::debugString (  )  [pure virtual]

Returns a debug-friendly representation of a Term

Returns:
a debug-friendly representation of a Term
Deprecated:

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

Returns:
the value (as an double) of an Integer or Float

Reimplemented in jpl::Float, and jpl::Integer.

Definition at line 181 of file Term.java.

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

Returns:
the value (as a float) of an Integer or Float

Reimplemented in jpl::Float, and jpl::Integer.

Definition at line 171 of file Term.java.

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.

Parameters:
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]

Just calls computeSubstitution for each Term in the array.

Parameters:
varnames_to_Terms a Map from variable names to Terms
vars_to_Vars a Map from Prolog variables to JPL Variables
arg a list of Terms

Definition at line 715 of file Term.java.

static Term jpl::Term::getTerm ( term_t  term  )  [inline, static, protected]

Definition at line 661 of file Term.java.

static Term jpl::Term::getTerm ( Map  vars_to_Vars,
term_t  term 
) [inline, static, protected]

Definition at line 609 of file Term.java.

static Term jpl::Term::getTerm1 ( Map  vars_to_Vars,
term_t  term 
) [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.

Parameters:
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.
Returns:
An array of converted Terms We discover the Prolog type of the term, then forward the call to the appropriate subclass
Parameters:
vars A Map from Prolog variables to jpl.Variable instances
term The Prolog term (in a term_t holder) to convert
Returns:
The converted Term subtype instance.

Reimplemented in jpl::Atom, jpl::Compound, jpl::Float, jpl::Integer, and jpl::Variable.

Definition at line 587 of file Term.java.

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

Returns:
whether this Term's functor has (double) 'name' and 'arity'

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

Returns:
whether this Term's functor has (int) 'name' and 'arity'

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

Returns:
whether this Term's functor has (String) 'name' and 'arity'

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

Returns:
the value (as an int) of an Integer or Float

Reimplemented in jpl::Float, and jpl::Integer.

Definition at line 153 of file Term.java.

boolean jpl::Term::isAtom (  )  [inline]

whether this Term represents an atom

Returns:
whether this Term represents an atom

Definition at line 208 of file Term.java.

boolean jpl::Term::isCompound (  )  [inline]

whether this Term represents a compound term

Returns:
whether this Term represents a compound atom

Definition at line 217 of file Term.java.

boolean jpl::Term::isFloat (  )  [inline]

whether this Term represents an atom

Returns:
whether this Term represents an atom

Definition at line 226 of file Term.java.

boolean jpl::Term::isInteger (  )  [inline]

whether this Term represents an atom

Returns:
whether this Term represents an atom

Definition at line 235 of file Term.java.

boolean jpl::Term::isJFalse (  )  [inline]

whether this Term is a 'jfalse' structure, i.e. @(false)

Returns:
whether this Term is a 'jfalse' structure, i.e. @(false)

Reimplemented in jpl::Compound.

Definition at line 253 of file Term.java.

boolean jpl::Term::isJNull (  )  [inline]

whether this Term is a 'jnull' structure, i.e. @(null)

Returns:
whether this Term is a 'jnull' structure, i.e. @(null)

Reimplemented in jpl::Compound.

Definition at line 271 of file Term.java.

boolean jpl::Term::isJObject (  )  [inline]

whether this Term is a 'jobject' structure, i.e. @(Tag)

Returns:
whether this Term is a 'jobject' structure, i.e. @(Tag)

Reimplemented in jpl::Compound.

Definition at line 289 of file Term.java.

boolean jpl::Term::isJRef (  )  [inline]

whether this Term is a 'jref' structure, i.e. @(Tag) or @(null)

Returns:
whether this Term is a 'jref' structure, i.e. @(Tag) or @(null)

Reimplemented in jpl::Compound.

Definition at line 298 of file Term.java.

boolean jpl::Term::isJTrue (  )  [inline]

whether this Term is a 'jtrue' structure, i.e. @(true)

Returns:
whether this Term is a 'jtrue' structure, i.e. @(true)

Reimplemented in jpl::Compound.

Definition at line 262 of file Term.java.

boolean jpl::Term::isJVoid (  )  [inline]

whether this Term is a 'jvoid' structure, i.e. @(void)

Returns:
whether this Term is a 'jvoid' structure, i.e. @(void)

Reimplemented in jpl::Compound.

Definition at line 280 of file Term.java.

boolean jpl::Term::isVariable (  )  [inline]

whether this Term is a variable

Returns:
whether this Term is a variable

Definition at line 244 of file Term.java.

abstract Object jpl::Term::jrefToObject (  )  [pure virtual]
int jpl::Term::listLength (  )  [inline]

the length of this list, iff it is one, else an exception is thrown

Exceptions:
JPLException 
Returns:
the length (as an int) of this list, iff it is one

Definition at line 358 of file Term.java.

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

Returns:
the value (as a long) of an Integer or Float

Reimplemented in jpl::Float, and jpl::Integer.

Definition at line 162 of file Term.java.

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

Returns:
the name of a Compound, Atom or Variable

Reimplemented in jpl::Compound, jpl::Float, jpl::Integer, and jpl::Variable.

Definition at line 133 of file Term.java.

static Term jpl::Term::objectToJRef ( Object  obj  )  [inline, static]

returns a new Term instance which represents the given object

Definition at line 308 of file Term.java.

abstract void jpl::Term::put ( Map  varnames_to_vars,
term_t  term 
) [protected, pure virtual]

Cache the reference to the Prolog term_t here.

Parameters:
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.

void jpl::Term::put ( term_t  term  )  [inline]

Definition at line 444 of file Term.java.

Term jpl::Term::putParams ( Term  plist  )  [inline]

Definition at line 322 of file Term.java.

Term jpl::Term::putParams ( Term[]  ps  )  [inline]

Definition at line 312 of file Term.java.

Term jpl::Term::putParams1 ( IntHolder  next,
Term[]  ps 
) [inline, protected]

Definition at line 327 of file Term.java.

static Term [] jpl::Term::putParams2 ( Term[]  ts,
IntHolder  next,
Term[]  ps 
) [inline, static, protected]

Definition at line 343 of file Term.java.

static void jpl::Term::putTerm ( Object  obj,
term_t  termref 
) [inline, static]

Definition at line 493 of file Term.java.

static term_t jpl::Term::putTerms ( Map  varnames_to_vars,
Term[]  args 
) [inline, static, protected]

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.

Parameters:
varnames_to_vars Map from variable names to JPL Variables.
args An array of jpl.Term references.
Returns:
consecutive term_t references (first of which is a structure)

Definition at line 470 of file Term.java.

static boolean jpl::Term::terms_equals ( Term[]  t1,
Term[]  t2 
) [inline, static, protected]

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).

Parameters:
t1 an array of Terms
t2 another array of Terms
Returns:
true if all of the Terms in the (same-length) arrays are pairwise equal

Definition at line 732 of file Term.java.

static String jpl::Term::toString ( Term[]  args  )  [inline, static]

Converts a list of Terms to a String.

Parameters:
args An array of Terms to convert
Returns:
String representation of a list of Terms

Definition at line 753 of file Term.java.

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

Exceptions:
JPLException 
Returns:
an array of terms which are the successive members of this list, if it is a list

Definition at line 373 of file Term.java.

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

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

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.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Defines


jpl
Author(s): Lorenz Moesenlechner
autogenerated on Fri Jan 11 09:40:31 2013