Public Member Functions | |
final Term | arg (int i) |
Term[] | args () |
String | debugString () |
final boolean | equals (Object obj) |
boolean | hasFunctor (double value, int arity) |
boolean | hasFunctor (int value, int arity) |
boolean | hasFunctor (String name, int arity) |
Object | jrefToObject () |
final String | name () |
String | toString () |
final int | type () |
String | typeName () |
Variable () | |
Variable (String name) | |
Public Attributes | |
final String | name |
Protected Member Functions | |
final void | getSubst (Map varnames_to_Terms, Map vars_to_Vars) |
final void | put (Map varnames_to_vars, term_t term) |
Static Protected Member Functions | |
static Term | getTerm1 (Map vars_to_Vars, term_t var) |
Protected Attributes | |
transient int | index |
transient term_t | term_ = null |
Private Member Functions | |
boolean | isValidName (String s) |
final boolean | tellThem () |
Static Private Attributes | |
static long | n = 0 |
This class supports Java representations of Prolog variables.
A jpl.Variable instance is equivalent to a variable in a fragment of Prolog source text: it is *not* a "live" variable within a Prolog stack or heap. A corresponding Prolog variable is created only upon opening a Query whose goal refers to a Variable (and then only temporarily).
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 65 of file Variable.java.
jpl::Variable::Variable | ( | String | name | ) | [inline] |
Create a new Variable with 'name' (which must not be null or ""), and may one day be constrained to comply with traditional Prolog syntax.
name | the source name of this Variable |
Definition at line 82 of file Variable.java.
jpl::Variable::Variable | ( | ) | [inline] |
Create a new Variable with new sequential name of the form "_261".
Definition at line 95 of file Variable.java.
final Term jpl::Variable::arg | ( | int | i | ) | [inline, virtual] |
throws a JPLException (arg(int) is defined only for Compound and Atom)
Implements jpl::Term.
Definition at line 169 of file Variable.java.
Term [] jpl::Variable::args | ( | ) | [inline, virtual] |
The (nonexistent) args of this Variable
JPLException |
Implements jpl::Term.
Definition at line 107 of file Variable.java.
String jpl::Variable::debugString | ( | ) | [inline, virtual] |
Returns a debug-friendly String representation of an Atom.
Implements jpl::Term.
Definition at line 211 of file Variable.java.
final boolean jpl::Variable::equals | ( | Object | obj | ) | [inline] |
A Variable is equal to another if their names are the same and they are not anonymous.
obj | The Object to compare. |
Definition at line 160 of file Variable.java.
final void jpl::Variable::getSubst | ( | Map | varnames_to_Terms, | |
Map | vars_to_Vars | |||
) | [inline, protected, virtual] |
If this Variable instance is not an anonymous or (in dont-tell-me mode) a dont-tell-me variable, and its binding is not already in the varnames_to_Terms Map, put the result of converting the term_t to which this variable has been unified to a Term in the Map, keyed on this Variable's name.
varnames_to_Terms | A Map of bindings from variable names to JPL Terms. | |
vars_to_Vars | A Map from Prolog variables to JPL Variables. |
Implements jpl::Term.
Definition at line 284 of file Variable.java.
Converts a term_t (known to refer to a Prolog variable) to a Variable. If the variable has already been seen (and hence converted), return its corresponding Variable from the map, else create a new Variable, stash it in the map (keyed by the Prolog variable), and return it.
vars_to_Vars | a map from Prolog to JPL variables | |
var | The term_t (known to be a variable) to convert |
Reimplemented from jpl::Term.
Definition at line 260 of file Variable.java.
boolean jpl::Variable::hasFunctor | ( | double | value, | |
int | arity | |||
) | [inline, virtual] |
Tests whether this Term's functor has (double) 'name' and 'arity' Returns false if called inappropriately
Implements jpl::Term.
Definition at line 116 of file Variable.java.
boolean jpl::Variable::hasFunctor | ( | int | value, | |
int | arity | |||
) | [inline, virtual] |
Tests whether this Term's functor has (int) 'name' and 'arity' Returns false if called inappropriately
Implements jpl::Term.
Definition at line 113 of file Variable.java.
boolean jpl::Variable::hasFunctor | ( | String | name, | |
int | arity | |||
) | [inline, virtual] |
Tests whether this Term's functor has (String) 'name' and 'arity' Returns false if called inappropriately
Implements jpl::Term.
Definition at line 110 of file Variable.java.
boolean jpl::Variable::isValidName | ( | String | s | ) | [inline, private] |
Tests the lexical validity of s as a variable's name
Definition at line 182 of file Variable.java.
Object jpl::Variable::jrefToObject | ( | ) | [inline, virtual] |
Implements jpl::Term.
Definition at line 119 of file Variable.java.
final String jpl::Variable::name | ( | ) | [inline] |
returns the lexical name of this Variable
Reimplemented from jpl::Term.
Definition at line 127 of file Variable.java.
final void jpl::Variable::put | ( | Map | varnames_to_vars, | |
term_t | term | |||
) | [inline, protected, virtual] |
To put a Variable, we must check whether a (non-anonymous) variable with the same name has already been put in the Term. If one has, then the corresponding Prolog variable has been stashed in the varnames_to_vars Map, keyed by the Variable name, so we can look it up and reuse it (this way, the sharing of variables in the Prolog term reflects the sharing of Variable names in the Term. Otherwise, if this Variable name has not already been seen in the Term, then we put a new Prolog variable and add it into the Map (keyed by this Variable name).
varnames_to_vars | A Map from variable names to Prolog variables. | |
term | A (previously created) term_t which is to be set to a (new or reused) Prolog variable. |
Implements jpl::Term.
Definition at line 231 of file Variable.java.
final boolean jpl::Variable::tellThem | ( | ) | [inline, private] |
Definition at line 294 of file Variable.java.
String jpl::Variable::toString | ( | ) | [inline] |
Returns a Prolog source text representation of this Variable
Definition at line 151 of file Variable.java.
final int jpl::Variable::type | ( | ) | [inline, virtual] |
returns the type of this subclass of Term, i.e. Prolog.VARIABLE
Implements jpl::Term.
Definition at line 135 of file Variable.java.
String jpl::Variable::typeName | ( | ) | [inline, virtual] |
returns the typeName of this subclass of Term, i.e. "Variable"
Implements jpl::Term.
Definition at line 143 of file Variable.java.
transient int jpl::Variable::index [protected] |
Definition at line 72 of file Variable.java.
long jpl::Variable::n = 0 [static, private] |
Definition at line 69 of file Variable.java.
final String jpl::Variable::name |
Definition at line 70 of file Variable.java.
transient term_t jpl::Variable::term_ = null [protected] |
Definition at line 71 of file Variable.java.