CiaoJava
Class PLTerm

java.lang.Object
  extended byCiaoJava.PLTerm
Direct Known Subclasses:
PLAtom, PLFloat, PLInteger, PLList, PLString, PLStructure, PLVariable

public abstract class PLTerm
extends java.lang.Object

Java representation of Prolog terms. Abstract class for representing generic Prolog terms. The rest of the term representation classes are childs of this one. This class contains data and code that are common to every term. It includes also the conversion mechanism between the Java representation of Prolog terms and the serialized representation received from Prolog.


Field Summary
static PLTerm fail
          Fail representation.
static PLTerm nil
          Empty list representation.
static PLTerm success
          Success representation.
 
Constructor Summary
PLTerm()
           
 
Method Summary
abstract  PLTerm copy()
          Duplication of Prolog terms.
abstract  boolean equals(PLTerm t)
          Comparison between Prolog terms.
 boolean isInteger()
          Integer test.
 boolean isList()
          List test.
 boolean isNil()
          Nil test.
abstract  boolean isRunnable()
          Execution test for Prolog objects.
 boolean isString()
          String test.
 boolean isStructure()
          Structure test.
 boolean isVariable()
          Variable test.
abstract  java.lang.Object javaRepr(CiaoJava.PLInterpreter i)
          Java representation of the Prolog term.
abstract  java.lang.String toString()
          String representation of the Prolog term.
 boolean unify(PLTerm term)
          Term unification.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

nil

public static final PLTerm nil
Empty list representation. This PLTerm constant represents the empty list.


success

public static final PLTerm success
Success representation. This PLAtom constant is used to send back to Prolog if a request with no return value has been successfully completed.


fail

public static final PLTerm fail
Fail representation. This PLAtom constant is used to send back to Prolog if a request has failed.

Constructor Detail

PLTerm

public PLTerm()
Method Detail

toString

public abstract java.lang.String toString()
String representation of the Prolog term.

Returns:
a String representing this term.

javaRepr

public abstract java.lang.Object javaRepr(CiaoJava.PLInterpreter i)
Java representation of the Prolog term. Is used to obtain the equivalent Java object.

Parameters:
i - PLInterpreter object used to interpret the Prolog representation of Java objects.
Returns:
a Java object representation of the Prolog term.

isRunnable

public abstract boolean isRunnable()
Execution test for Prolog objects.

Returns:
true if this Prolog term can be evaluated in the Prolog side as a goal; false otherwise.

equals

public abstract boolean equals(PLTerm t)
Comparison between Prolog terms.

Parameters:
t - Term to be compared to.
Returns:
true if this Prolog term is equal to the term received as argument; false otherwise.

copy

public abstract PLTerm copy()
Duplication of Prolog terms. Performs an in depth term duplication, so that will be no shared elements between this term and the copy returned. The implementation of this method in the PLList, PLStructure and PLVariable clases perform the duplication recursively.

Returns:
a copy of this Prolog term.

unify

public boolean unify(PLTerm term)
Term unification. Unifies this Prolog term with the term received as argument.

Important: The unification is 'two sided': the variables found in the term received as argument could be bound in order to unify the complete terms. In the same way, the variables found in this term could be bound to unify both terms.

Parameters:
term - Term to unify with.
Returns:
true if the unification is successful: false otherwise.

isVariable

public boolean isVariable()
Variable test.

Returns:
true if this Prolog term is a variable; false otherwise.

isStructure

public boolean isStructure()
Structure test.

Returns:
true if this Prolog term is a structure; false otherwise.

isList

public boolean isList()
List test.

Returns:
true if this Prolog term is a list; false otherwise.

isString

public boolean isString()
String test.

Returns:
true if this Prolog term is a string; false otherwise.

isNil

public boolean isNil()
Nil test.

Returns:
true if this Prolog term is nil; false otherwise.

isInteger

public boolean isInteger()
Integer test.

Returns:
true if this Prolog term is an integer; false otherwise.