|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--CiaoJava.PLTerm
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 | |
(package private) static int |
ATOM
|
private static java.lang.String[] |
AtomTable
|
private static char |
currentVersion
|
static PLTerm |
fail
Fail representation. |
(package private) static int |
FLOAT
|
(package private) static int |
INTEGER
|
private static java.lang.String |
INTERPRETER_ERROR
|
private static java.lang.String |
INTERPRETER_SUCCESS
|
(package private) static java.lang.String |
JAVA_OBJECT
|
(package private) static int |
LIST
|
private static int |
MAX_READ_BUFFER
|
static PLTerm |
nil
Empty list representation. |
private static char |
PFX_ATOM
|
private static char |
PFX_FLOAT
|
private static char |
PFX_LIST_WITH_NIL_TAIL
|
private static char |
PFX_LIST_WITH_NONIL_TAIL
|
private static char |
PFX_LONG_INT
|
private static char |
PFX_MULTI_REF_ATOM
|
private static char |
PFX_MULTI_REF_STRUCT
|
private static char |
PFX_MULTI_REF_VAR
|
private static char |
PFX_SHORT_INT
|
private static char |
PFX_SINGLE_REF_VAR
|
private static char |
PFX_STRUCT
|
private static char |
PFXC_ATOM
|
private static char |
PFXC_FLOAT
|
private static char |
PFXC_INTEGER
|
private static char |
PFXC_LIST
|
private static char |
PFXC_NIL
|
private static char |
PFXC_STRING
|
private static char |
PFXC_STRUCT
|
private static char |
PFXC_VARIABLE
|
(package private) static java.lang.String |
PROLOG_EXCEPTION
|
(package private) static java.lang.String |
PROLOG_FAIL
|
(package private) static java.lang.String |
PROLOG_QUERY_ID
|
(package private) static java.lang.String |
PROLOG_SUCCESS
|
(package private) static int |
STRING
|
private static int |
STRING_BUFFER_SIZE
|
(package private) static int |
STRUCTURE
|
static PLTerm |
success
Success representation. |
int |
Type
|
private static int |
VarCounter
|
(package private) static int |
VARIABLE
|
private static int |
VarNumber
|
static char |
VERSION_A
|
static char |
VERSION_C
|
Constructor Summary | |
PLTerm()
|
Method Summary | |
void |
backtrack(PLTerm term)
Undo the unification made on this PLTerm object
using as pattern the term received as argument. |
abstract PLTerm |
copy()
Duplication of Prolog terms. |
abstract boolean |
equals(PLTerm t)
Comparison between Prolog terms. |
protected static PLTerm |
fastRead(java.io.BufferedReader in)
Conversion from Prolog low level format to a Java object. |
java.lang.String |
fastWrite()
Translation from a Java object to Prolog low level representation. |
private java.lang.StringBuffer |
genPrefix(PLTerm t)
Prefix generation in $fast format. |
private java.lang.StringBuffer |
genTerm(PLTerm t)
Term generation in $fast format. |
private static char |
getChar(java.io.BufferedReader in)
Gets one char from the reader received as argument. |
private static float |
getFloat(java.io.BufferedReader in)
Gets a float from the buffer until '\0' is found. |
private static int |
getInt(java.io.BufferedReader in)
Gets an integer from the buffer until '\0' is found. |
private static void |
getPrefix(java.io.BufferedReader in)
Gets the prefix of a Prolog low level fast format term. |
private static java.lang.String |
getString(java.io.BufferedReader in)
Gets a substring from the buffer until '\0' is found. |
private static PLTerm |
getTerm(java.io.BufferedReader in)
gets a term from the buffer in 'fast' format. |
protected boolean |
isException()
Prolog exception test. |
boolean |
isList()
List test. |
boolean |
isNil()
Nil test. |
protected boolean |
isPrologFail()
Prolog fail test. |
protected boolean |
isPrologSuccess()
Prolog success test. |
protected boolean |
isQueryId()
Prolog query id test. |
abstract boolean |
isRunnable()
Execution test for Prolog objects. |
protected boolean |
isSolution()
Prolog solution test. |
boolean |
isString()
String test. |
boolean |
isStructure()
Structure test. |
boolean |
isVariable()
Variable test. |
abstract java.lang.Object |
javaRepr(PLInterpreter i)
Java representation of the Prolog term. |
void |
launchGoal(java.io.PrintWriter out)
Execution of a Prolog goal. |
protected abstract int |
numberOfCells()
Number of cells on the Prolog WAM heap for this 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 |
|
Field Detail |
public int Type
static final int INTEGER
static final int FLOAT
static final int ATOM
static final int LIST
static final int STRUCTURE
static final int VARIABLE
static final int STRING
private static final java.lang.String INTERPRETER_ERROR
private static final java.lang.String INTERPRETER_SUCCESS
public static final PLTerm nil
PLTerm
constant
represents the empty list.public static final PLTerm success
PLAtom
constant
is used to send back to Prolog if a request with no
return value has been successfully completed.public static final PLTerm fail
PLAtom
constant
is used to send back to Prolog if a request has
failed.static final java.lang.String JAVA_OBJECT
static final java.lang.String PROLOG_EXCEPTION
static final java.lang.String PROLOG_FAIL
static final java.lang.String PROLOG_SUCCESS
static final java.lang.String PROLOG_QUERY_ID
private static java.lang.String[] AtomTable
private static int VarNumber
private static int VarCounter
private static final int STRING_BUFFER_SIZE
private static final int MAX_READ_BUFFER
public static final char VERSION_A
private static final char PFX_LIST_WITH_NIL_TAIL
private static final char PFX_LIST_WITH_NONIL_TAIL
private static final char PFX_SHORT_INT
private static final char PFX_LONG_INT
private static final char PFX_FLOAT
private static final char PFX_MULTI_REF_VAR
private static final char PFX_SINGLE_REF_VAR
private static final char PFX_ATOM
private static final char PFX_MULTI_REF_ATOM
private static final char PFX_STRUCT
private static final char PFX_MULTI_REF_STRUCT
public static final char VERSION_C
private static final char PFXC_LIST
private static final char PFXC_STRING
private static final char PFXC_INTEGER
private static final char PFXC_FLOAT
private static final char PFXC_VARIABLE
private static final char PFXC_ATOM
private static final char PFXC_STRUCT
private static final char PFXC_NIL
private static final char currentVersion
Constructor Detail |
public PLTerm()
Method Detail |
public abstract java.lang.String toString()
String
representing this term.public abstract java.lang.Object javaRepr(PLInterpreter i)
i
- PLInterpreter
object used
to interpret the Prolog representation
of Java objects.public abstract boolean isRunnable()
true
if this Prolog term can
be evaluated in the Prolog side as a goal;
false
otherwise.public abstract boolean equals(PLTerm t)
t
- Term to be compared to.true
if this Prolog term is
equal to the term received as argument;
false
otherwise.protected abstract int numberOfCells()
public abstract PLTerm copy()
PLList
, PLStructure
and PLVariable
clases perform the
duplication recursively.public void launchGoal(java.io.PrintWriter out) throws PLGoalException
out
- socket descriptor for sending the
goal description to Prolog.public boolean unify(PLTerm term)
term
- Term to unify with.public void backtrack(PLTerm term) throws PLException
PLTerm
object
using as pattern the term received as argument.
This is the most general code.
For PLList, PLStructure and PLVariable there are specific code
that overrides this method.term
- Term to be used as pattern.public boolean isVariable()
true
if this Prolog term is a variable;
false
otherwise.public boolean isStructure()
true
if this Prolog term is a structure;
false
otherwise.public boolean isList()
true
if this Prolog term is a list;
false
otherwise.public boolean isString()
true
if this Prolog term is a string;
false
otherwise.public boolean isNil()
true
if this Prolog term is nil;
false
otherwise.protected boolean isException()
true
if the term represents a
Prolog exception;
false
otherwise.protected boolean isPrologFail()
true
if the term represents the valid
Prolog atom used to indicate goal fail;
false
otherwise.protected boolean isPrologSuccess()
true
if the term represents the valid
Prolog atom used to indicate Prolog success;
false
otherwise.protected boolean isQueryId()
true
if the term represents the valid
Prolog structure used to indicate a query id;
false
otherwise.protected boolean isSolution()
true
if the term represents the valid
Prolog structure used to indicate a query solution;
false
otherwise.protected static PLTerm fastRead(java.io.BufferedReader in) throws PLException
PLTerm
representation of the term
received.in
- Reader from which the term will be read.private static void getPrefix(java.io.BufferedReader in) throws PLException
in
- Reader from which the term will be read.private static int getInt(java.io.BufferedReader in) throws PLException
in
- Reader from which the term will be read.PLException
- if the integer
received is not a valid Java integer.private static float getFloat(java.io.BufferedReader in) throws PLException
in
- Reader from which the term will be read.PLException
- if the float received
is not a valid Java float.private static char getChar(java.io.BufferedReader in) throws PLException
in
- Reader from which the term will be read.PLException
- if the BufferedReader
does not allow more read operations.private static java.lang.String getString(java.io.BufferedReader in) throws PLException
in
- Reader from which the term will be read.PLException
- if the BufferedReader
does not allow more read operations, and '\0'
is missing.private static PLTerm getTerm(java.io.BufferedReader in) throws PLException
in
- Reader from which the term will be read.PLException
- if there is any problem
during the term parsing.public java.lang.String fastWrite()
private java.lang.StringBuffer genPrefix(PLTerm t)
t
- Prolog term for which build a prefix in
low level format.StringBuffer
object that
contains the prefix.private java.lang.StringBuffer genTerm(PLTerm t)
t
- Prolog term to translate to low level formatStringBuffer
object that
contains the low level term representation.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |