|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--CiaoJava.PLTerm | +--CiaoJava.PLVariable
Prolog variables representation. This class represents a Prolog variable, to provide a Prolog style of variable instancing. This class uses the characteristic Java representation of objects as references. If the object referenced by a variable changes, the variable content will change too. This allows to provide a Prolog behaviour of Java variables containing PLVariable objects.
Field Summary | |
(package private) PLTerm |
Binding
|
private static int |
lastRef
|
private int |
SINGLE_REF
|
(package private) int |
VarNumber
|
Constructor Summary | |
PLVariable()
Creates a new Prolog variable and references it to a free variable number. |
|
PLVariable(int number)
Creates a new Prolog variable with a given variable number. |
Method Summary | |
void |
backtrack(PLTerm term)
Undo the unification made on this variable using as pattern the term received as argument. |
void |
bind(PLTerm term)
Variable binding. |
PLTerm |
copy()
Makes a full copy of this PLVariable Prolog variable
object. |
boolean |
equals(PLTerm t)
Strict comparison between Prolog terms. |
PLTerm |
getBinding()
Returns the binding of this Prolog variable. |
int |
getNumber()
Returns the internal variable number. |
boolean |
isFree()
free variable test. |
boolean |
isRunnable()
Execution test on Prolog objects. |
java.lang.Object |
javaRepr(PLInterpreter i)
Java representation of a variable: just itself. |
protected int |
numberOfCells()
|
java.lang.String |
toString()
Returns the string representation of this Prolog variable If the variable is bound to a Prolog term, this term is also represented enclosed between brackets. |
void |
unbind()
Variable unbinding. |
boolean |
unify(PLTerm term)
Term unification. |
Methods inherited from class CiaoJava.PLTerm |
fastRead,
fastWrite,
genPrefix,
genTerm,
getChar,
getFloat,
getInt,
getPrefix,
getString,
getTerm,
isException,
isList,
isNil,
isPrologFail,
isPrologSuccess,
isQueryId,
isSolution,
isString,
isStructure,
isVariable,
launchGoal |
Methods inherited from class java.lang.Object |
|
Field Detail |
int VarNumber
PLTerm Binding
private final int SINGLE_REF
private static int lastRef
Constructor Detail |
public PLVariable()
public PLVariable(int number)
number
- variable number.Method Detail |
public boolean isFree()
true
if this Prolog variable is unbound<
false
if is bound to anothe Prolog term.public PLTerm getBinding()
public int getNumber()
public void bind(PLTerm term)
term
- Term to bind to.public void unbind()
null
to the binding attribute.public java.lang.String toString()
public java.lang.Object javaRepr(PLInterpreter i)
public boolean isRunnable()
PLTerm
abstract method.false
.public boolean equals(PLTerm t)
true
if the PLTerm
object
is exactly a PLVariable
object and
has the same variable number<
false
otherwise.public PLTerm copy()
PLVariable
Prolog variable
object. Recursively clones the term bound by this variable, in order
to create a new PLVariable
with no shared components.PLTerm
object with a copy of this variable
and its contents.public boolean unify(PLTerm term)
term
- Term to unify with.true
if the unification is successful: false otherwise.public void backtrack(PLTerm term) throws PLException
term
- PLTerm
object that contains the
PLVariable
object with the content
to be stored on this variable.protected int numberOfCells()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |