public class Variable extends Term
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.
Modifier and Type | Field and Description |
---|---|
protected int |
index |
java.lang.String |
name
the name of this Variable
|
protected term_t |
term_
defined between Query.open() and Query.get2()
|
Constructor and Description |
---|
Variable()
Create a new Variable with new sequential name of the form "_261".
|
Variable(java.lang.String name)
Create a new Variable with 'name' (which must not be null or ""), and may one day be constrained to comply with traditional Prolog syntax.
|
Modifier and Type | Method and Description |
---|---|
Term[] |
args()
The (nonexistent) args of this Variable
|
int |
arity()
returns, as an int, the arity of a Term
|
boolean |
equals(java.lang.Object obj)
A Variable is equal to another if their names are the same and they are not anonymous.
|
protected void |
getSubst(java.util.Map<java.lang.String,Term> varnames_to_Terms,
java.util.Map<term_t,Variable> vars_to_Vars)
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.
|
boolean |
hasFunctor(double value,
int arity)
Tests whether this Term's functor has (double) 'name' and 'arity' Returns false if called inappropriately
|
boolean |
hasFunctor(int value,
int arity)
Tests whether this Term's functor has (int) 'name' and 'arity' Returns false if called inappropriately
|
boolean |
hasFunctor(java.lang.String name,
int arity)
Tests whether this Term's functor has (String) 'name' and 'arity' Returns false if called inappropriately
|
java.lang.String |
name()
the lexical name of this Variable
|
protected void |
put(java.util.Map<java.lang.String,term_t> varnames_to_vars,
term_t term)
To put a Variable, we must check whether a (non-anonymous) variable with the same name has already been put in the Term.
|
java.lang.String |
toString()
Returns a Prolog source text representation of this Variable
|
int |
type()
returns the type of this subclass of Term, i.e.
|
java.lang.String |
typeName()
returns the typeName of this subclass of Term, i.e.
|
arg, atomType, bigValue, doubleValue, floatValue, getSubsts, getTerm, getTerm, intValue, isAtom, isBigInteger, isCompound, isFloat, isInteger, isJFalse, isJNull, isJObject, isJRef, isJTrue, isJVoid, isListNil, isListPair, isVariable, jrefToObject, listLength, longValue, objectToJRef, put, putParams, putParams, putParams1, putParams2, putTerm, putTerms, terms_equals, toString, toTermArray
protected transient int index
public final java.lang.String name
protected transient term_t term_
public Variable()
public Variable(java.lang.String name)
name
- the source name of this Variablepublic Term[] args()
args
in class Term
JPLException
public int arity()
public final boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- The Object to compare.protected final void getSubst(java.util.Map<java.lang.String,Term> varnames_to_Terms, java.util.Map<term_t,Variable> vars_to_Vars)
public boolean hasFunctor(java.lang.String name, int arity)
Term
hasFunctor
in class Term
public boolean hasFunctor(int value, int arity)
Term
hasFunctor
in class Term
public boolean hasFunctor(double value, int arity)
Term
hasFunctor
in class Term
public final java.lang.String name()
protected final void put(java.util.Map<java.lang.String,term_t> varnames_to_vars, term_t term)
public java.lang.String toString()
toString
in class java.lang.Object
public final int type()