CiaoJava
Class PLString
java.lang.Object
|
+--CiaoJava.PLTerm
|
+--CiaoJava.PLString
- public class PLString
- extends PLTerm
This class implements the Java representation of a Prolog string.
Although in Prolog strings are represented as lists of integers,
internally a more eficient implementation is made. The Java side
of this interface has implemented the string representation
accordingly to the byte representation given by the serialization
mechanism.
Field Summary |
private java.lang.String |
Value
|
Fields inherited from class CiaoJava.PLTerm |
ATOM,
AtomTable,
currentVersion,
fail,
FLOAT,
INTEGER,
INTERPRETER_ERROR,
INTERPRETER_SUCCESS,
JAVA_OBJECT,
LIST,
MAX_READ_BUFFER,
nil,
PFX_ATOM,
PFX_FLOAT,
PFX_LIST_WITH_NIL_TAIL,
PFX_LIST_WITH_NONIL_TAIL,
PFX_LONG_INT,
PFX_MULTI_REF_ATOM,
PFX_MULTI_REF_STRUCT,
PFX_MULTI_REF_VAR,
PFX_SHORT_INT,
PFX_SINGLE_REF_VAR,
PFX_STRUCT,
PFXC_ATOM,
PFXC_FLOAT,
PFXC_INTEGER,
PFXC_LIST,
PFXC_NIL,
PFXC_STRING,
PFXC_STRUCT,
PFXC_VARIABLE,
PROLOG_EXCEPTION,
PROLOG_FAIL,
PROLOG_QUERY_ID,
PROLOG_SUCCESS,
STRING,
STRING_BUFFER_SIZE,
STRUCTURE,
success,
Type,
VarCounter,
VARIABLE,
VarNumber,
VERSION_A,
VERSION_C |
Constructor Summary |
PLString(java.lang.String s)
Given a Java string, creates a Java PLString
object. |
Method Summary |
PLTerm |
copy()
Makes a full copy of this PLString
object. |
boolean |
equals(PLTerm t)
Compares this PLString object with the PLTerm given as
argument. |
java.lang.String |
getValue()
Gets the value of a Prolog string object. |
boolean |
isRunnable()
Execution test on Prolog objects. |
java.lang.Object |
javaRepr(PLInterpreter i)
Java representation of a PLString . |
int |
length()
Returns the number of characters of this PLString . |
protected int |
numberOfCells()
Returns the number of cells needed to represent
this PLString in the Prolog heap. |
java.lang.String |
toString()
String representation of a Java PLString object. |
Methods inherited from class CiaoJava.PLTerm |
backtrack,
fastRead,
fastWrite,
genPrefix,
genTerm,
getChar,
getFloat,
getInt,
getPrefix,
getString,
getTerm,
isException,
isList,
isNil,
isPrologFail,
isPrologSuccess,
isQueryId,
isSolution,
isString,
isStructure,
isVariable,
launchGoal,
unify |
Methods inherited from class java.lang.Object |
,
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
registerNatives,
wait,
wait,
wait |
Value
private java.lang.String Value
PLString
public PLString(java.lang.String s)
- Given a Java string, creates a Java
PLString
object.
- Parameters:
s
- String that will contain the Prolog string.
toString
public java.lang.String toString()
- String representation of a Java PLString object.
- Returns:
- a Java string with a copy of the Prolog string.
- Overrides:
- toString in class PLTerm
getValue
public java.lang.String getValue()
- Gets the value of a Prolog string object.
- Returns:
- the value of this Prolog string object.
javaRepr
public java.lang.Object javaRepr(PLInterpreter i)
- Java representation of a
PLString
. Creates a copy
of the value of this PLString
and returns it.
- Parameters:
i
- PLInterpreter
object used to
obtain the Java representation. Included
here only for compatibility purposes.- Returns:
- a Java object representation of this Prolog string.
- Overrides:
- javaRepr in class PLTerm
isRunnable
public boolean isRunnable()
- Execution test on Prolog objects. Returns true if the
related Prolog term can be evaluated. Included here
only for compatibility purposes.
- Returns:
- Always
false
. - Overrides:
- isRunnable in class PLTerm
equals
public boolean equals(PLTerm t)
- Compares this
PLString
object with the PLTerm
given as
argument. Implementation of the method inherited from PLTerm.
- Parameters:
t
- Prolog term to be compared to.- Returns:
true
if this Prolog string is equal
to the term received as argument;
false
otherwise.- Overrides:
- equals in class PLTerm
copy
public PLTerm copy()
- Makes a full copy of this
PLString
object.
- Returns:
- a copy of this Prolog term.
- Overrides:
- copy in class PLTerm
length
public int length()
- Returns the number of characters of this
PLString
.
- Returns:
- The number of characters of this Prolog string.
numberOfCells
protected int numberOfCells()
- Returns the number of cells needed to represent
this PLString in the Prolog heap. Only used for
$fast_read format version 'a'.
- Returns:
- 0 (no cells used).
- Overrides:
- numberOfCells in class PLTerm