CiaoJava
Class PLString

java.lang.Object
  extended byCiaoJava.PLTerm
      extended byCiaoJava.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
 
Fields inherited from class CiaoJava.PLTerm
fail, nil, success
 
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()
          Java representation of a PLString.
 java.lang.Object javaRepr(CiaoJava.PLInterpreter i)
          Java representation of a PLString.
 int length()
          Returns the number of characters of this PLString.
 PLList toPLList()
          Converts this Prolog string into a Prolog list of ASCII codes of this string.
 java.lang.String toString()
          String representation of a Java PLString object.
 
Methods inherited from class CiaoJava.PLTerm
isInteger, isList, isNil, isString, isStructure, isVariable, unify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

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.
Method Detail

toString

public java.lang.String toString()
String representation of a Java PLString object.

Specified by:
toString in class PLTerm
Returns:
a Java string with a copy of the Prolog string.

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(CiaoJava.PLInterpreter i)
Java representation of a PLString. Creates a copy of the value of this PLString and returns it.

Specified by:
javaRepr in class PLTerm
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.

javaRepr

public java.lang.Object javaRepr()
Java representation of a PLString. Creates a copy of the value of this PLString and returns it.

Returns:
a Java object representation of this Prolog string.

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.

Specified by:
isRunnable in class PLTerm
Returns:
Always false.

equals

public boolean equals(PLTerm t)
Compares this PLString object with the PLTerm given as argument. Implementation of the method inherited from PLTerm.

Specified by:
equals in class 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.

copy

public PLTerm copy()
Makes a full copy of this PLString object.

Specified by:
copy in class PLTerm
Returns:
a copy of this Prolog term.

length

public int length()
Returns the number of characters of this PLString.

Returns:
The number of characters of this Prolog string.

toPLList

public PLList toPLList()
                throws PLException
Converts this Prolog string into a Prolog list of ASCII codes of this string.

Returns:
the list of ASCII codes of this Prolog string.
Throws:
PLException