|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectCiaoJava.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 |
Fields inherited from class CiaoJava.PLTerm |
fail, nil, success |
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. |
boolean |
isFree()
free variable test. |
boolean |
isRunnable()
Execution test on Prolog objects. |
java.lang.Object |
javaRepr(CiaoJava.PLInterpreter i)
Java representation of a variable: just itself. |
java.lang.String |
toString()
Returns the string representation of this Prolog variable. |
void |
unbind()
Variable unbinding. |
boolean |
unify(PLTerm term)
Term unification. |
Methods inherited from class CiaoJava.PLTerm |
isInteger, isList, isNil, isString, isStructure, isVariable |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
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 void bind(PLTerm term)
term
- Term to bind to.public void unbind()
null
to the binding attribute.
public java.lang.String toString()
toString
in class PLTerm
public java.lang.Object javaRepr(CiaoJava.PLInterpreter i)
javaRepr
in class PLTerm
i
- PLInterpreter
object used
to interpret the Prolog representation
of Java objects.
public boolean isRunnable()
PLTerm
abstract method.
isRunnable
in class PLTerm
false
.public boolean equals(PLTerm t)
equals
in class PLTerm
t
- Term to be compared to.
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.
copy
in class PLTerm
PLTerm
object with a copy of this variable
and its contents.public boolean unify(PLTerm term)
unify
in class PLTerm
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.
PLException
- if this term cannot be backtracked.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |