CiaoJava
Class PLInteger

java.lang.Object
  |
  +--CiaoJava.PLTerm
        |
        +--CiaoJava.PLInteger

public class PLInteger
extends PLTerm

Prolog integer representation. This implementation can only work with Prolog integers that fit in Java Integer type. The Long representation cannot be used due to the importance of integer numbers for almost every class in the Java API.


Field Summary
(package private)  java.lang.Integer Value
          Value of the Prolog integer.
 
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
PLInteger(int v)
          Integer constructor.
 
Method Summary
 PLTerm copy()
          Makes a full copy of this PLInteger object.
 boolean equals(PLTerm t)
          comparison between Prolog terms.
 int getValue()
          Gets the integer value of the PLInteger object.
 boolean isRunnable()
          Execution test on Prolog objects.
 java.lang.Object javaRepr(PLInterpreter i)
          Gets the Java representation of this Prolog integer as an object.
protected  int numberOfCells()
          Number of cells used in the internal Prolog representation.
 java.lang.String toString()
          String representation.
 
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
 

Field Detail

Value

java.lang.Integer Value
Value of the Prolog integer.
Constructor Detail

PLInteger

public PLInteger(int v)
Integer constructor. Creates a new PLInteger object with initial value given as argument.
Parameters:
v - Initial value of this PLInteger object. This argument must be the largest representation of an integral number to manage Prolog integers.
Method Detail

toString

public java.lang.String toString()
String representation. Returns the String representation of this PLInteger object.
Returns:
The string representation of this PLInteger object.
Overrides:
toString in class PLTerm

javaRepr

public java.lang.Object javaRepr(PLInterpreter i)
Gets the Java representation of this Prolog integer as an object. The object returned must be a Java Integer object.
Parameters:
i - PLInterpreter object to interpret the this Prolog term (although is not needed in this method, this parameter is included here for compatibility with the abstract declaration in PLTerm).
Returns:
An Object representing the Prolog integer. This object will be a Java Integer object.
Overrides:
javaRepr in class PLTerm

getValue

public int getValue()
Gets the integer value of the PLInteger object.
Returns:
The primitive int value of this Prolog integer.

isRunnable

public boolean isRunnable()
Execution test on Prolog objects. Returns true if the related Prolog term can be evaluated. Included here for compatibility with the PLTerm class.
Returns:
Always false.
Overrides:
isRunnable in class PLTerm

equals

public boolean equals(PLTerm t)
comparison between Prolog terms.
Parameters:
t - Prolog term to compare to.
Returns:
true if the PLTerm received as argument is equal to this PLInteger object.
Overrides:
equals in class PLTerm

copy

public PLTerm copy()
Makes a full copy of this PLInteger object. Creates a new PLInteger object with the integer value of this object.
Returns:
A new PLInteger with the value of this object.
Overrides:
copy in class PLTerm

numberOfCells

protected int numberOfCells()
Number of cells used in the internal Prolog representation. This function is only needed for $fast format generation in Prolog $fast_read version 'a'. This will NOT work if the internal Prolog representation of this integer needs a structure (large integer representation).
Overrides:
numberOfCells in class PLTerm