Prolog Cafe v1.2

jp.ac.kobe_u.cs.prolog.lang
Class IntegerTerm

java.lang.Object
  extended by jp.ac.kobe_u.cs.prolog.lang.Term
      extended by jp.ac.kobe_u.cs.prolog.lang.NumberTerm
          extended by jp.ac.kobe_u.cs.prolog.lang.IntegerTerm
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Term>

public class IntegerTerm
extends NumberTerm

Integer.
The class IntegerTerm wraps a value of primitive type int.

   Term t = new IntegerTerm(100);
   int i = ((IntegerTerm)t).intValue();
 

See Also:
Serialized Form

Field Summary
protected  int val
          Holds an int value that this IntegerTerm represents.
 
Fields inherited from class jp.ac.kobe_u.cs.prolog.lang.Term
AFTER, BEFORE, EQUAL
 
Constructor Summary
IntegerTerm(int i)
          Constructs a new Prolog integer that represents the specified int value.
IntegerTerm(java.lang.String i)
          Constructs a new Prolog integer that represents integer value of specified String parameter.
 
Method Summary
 NumberTerm abs()
          Returns a NumberTerm whose value is abs(this).
 NumberTerm acos()
          Returns a NumberTerm whose value is acos(this).
 NumberTerm add(NumberTerm t)
          Returns a NumberTerm whose value is (this + t).
 NumberTerm and(NumberTerm t)
          Returns a NumberTerm whose value is (this & t).
 int arithCompareTo(NumberTerm t)
          Compares two NumberTerm objects numerically.
 NumberTerm asin()
          Returns a NumberTerm whose value is asin(this).
 NumberTerm atan()
          Returns a NumberTerm whose value is tan(this).
 NumberTerm ceil()
          Returns a NumberTerm whose value is ceil(this).
 int compareTo(Term anotherTerm)
          Compares two terms in Prolog standard order of terms.
 boolean convertible(java.lang.Class type)
          Check whether this object is convertible with the given Java class type.
 NumberTerm cos()
          Returns a NumberTerm whose value is cos(this).
 NumberTerm divide(NumberTerm t)
          Returns a NumberTerm whose value is (this / t).
 double doubleValue()
          Returns the numeric value represented by this object after conversion to type double.
 boolean equals(java.lang.Object obj)
          Checks term equality of two terms.
 NumberTerm exp()
          Returns a NumberTerm whose value is exp(this).
 NumberTerm floatFractPart()
          Returns a NumberTerm whose value is the float-fractional-part of this.
 NumberTerm floatIntPart()
          Returns a NumberTerm whose value is the float-integer-part of this.
 NumberTerm floor()
          Returns a NumberTerm whose value is floor(this).
 int hashCode()
           
 NumberTerm intDivide(NumberTerm t)
          Returns a NumberTerm whose value is (int)(this / t).
 int intValue()
          Returns the numeric value represented by this object after conversion to type int.
 NumberTerm log()
          Returns a NumberTerm whose value is log(this).
 long longValue()
          Returns the numeric value represented by this object after conversion to type long.
 NumberTerm max(NumberTerm t)
          Returns a NumberTerm whose value is max(this, t).
 NumberTerm min(NumberTerm t)
          Returns a NumberTerm whose value is min(this, t).
 NumberTerm mod(NumberTerm t)
          Returns a NumberTerm whose value is (this mod t).
 NumberTerm multiply(NumberTerm t)
          Returns a NumberTerm whose value is (this * t).
 NumberTerm negate()
          Returns a NumberTerm whose value is (- this).
 NumberTerm not()
          Returns a NumberTerm whose value is (~ this).
 NumberTerm or(NumberTerm t)
          Returns a NumberTerm whose value is (this | t).
 NumberTerm pow(NumberTerm t)
          Returns a NumberTerm whose value is (thist).
 NumberTerm rint()
          Returns a NumberTerm whose value is rint(this).
 NumberTerm round()
          Returns a NumberTerm whose value is round(this).
 NumberTerm shiftLeft(NumberTerm t)
          Returns a NumberTerm whose value is (this << t).
 NumberTerm shiftRight(NumberTerm t)
          Returns a NumberTerm whose value is (this >> t).
 NumberTerm signum()
          Returns a NumberTerm whose value is signum(this).
 NumberTerm sin()
          Returns a NumberTerm whose value is sin(this).
 NumberTerm sqrt()
          Returns a NumberTerm whose value is sqrt(this).
 NumberTerm subtract(NumberTerm t)
          Returns a NumberTerm whose value is (this - t).
 NumberTerm tan()
          Returns a NumberTerm whose value is tan(this).
 NumberTerm toDegrees()
          Returns a NumberTerm whose value is toDegrees(this).
 NumberTerm toFloat()
          Returns a NumberTerm whose value is (double)(this).
 java.lang.Object toJava()
          Returns a java.lang.Integer corresponds to this IntegerTerm according to Prolog Cafe interoperability with Java.
 NumberTerm toRadians()
          Returns a NumberTerm whose value is toRadians(this).
 java.lang.String toString()
          Returns a string representation of this IntegerTerm.
 NumberTerm truncate()
          Returns a NumberTerm whose value is the truncate of this.
 boolean unify(Term t, Trail trail)
          Checks whether the argument term is unified with this one.
 int value()
          Returns the value of val.
 NumberTerm xor(NumberTerm t)
          Returns a NumberTerm whose value is (this ^ t).
 
Methods inherited from class jp.ac.kobe_u.cs.prolog.lang.Term
convertible, copy, dereference, instanceOfTerm, isClosure, isDouble, isGround, isInteger, isJavaObject, isList, isNil, isNumber, isStructure, isSymbol, isVariable, toQuotedString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

val

protected int val
Holds an int value that this IntegerTerm represents.

Constructor Detail

IntegerTerm

public IntegerTerm(int i)
Constructs a new Prolog integer that represents the specified int value.


IntegerTerm

public IntegerTerm(java.lang.String i)
Constructs a new Prolog integer that represents integer value of specified String parameter.

Throws:
java.lang.NumberFormatException - if the String does not contain a parsable integer.
Method Detail

value

public int value()
Returns the value of val.

See Also:
val

unify

public boolean unify(Term t,
                     Trail trail)
Description copied from class: Term
Checks whether the argument term is unified with this one.

Specified by:
unify in class Term
Parameters:
t - the term to be unified with.
trail - Trail Stack.
Returns:
true if succeeds, otherwise false.

convertible

public boolean convertible(java.lang.Class type)
Description copied from class: Term
Check whether this object is convertible with the given Java class type.

Overrides:
convertible in class Term
Parameters:
type - the Java class type to compare with.
Returns:
the boolean whose value is convertible(Integer.class, type).
See Also:
Term.convertible(Class, Class)

toJava

public java.lang.Object toJava()
Returns a java.lang.Integer corresponds to this IntegerTerm according to Prolog Cafe interoperability with Java.

Overrides:
toJava in class Term
Returns:
a java.lang.Integer object equivalent to this IntegerTerm.

toString

public java.lang.String toString()
Returns a string representation of this IntegerTerm.

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Checks term equality of two terms. The result is true if and only if the argument is an instance of IntegerTerm and has the same int value as this object.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare with. This must be dereferenced.
Returns:
true if the given object represents a Prolog integer equivalent to this IntegerTerm, false otherwise.
See Also:
compareTo(jp.ac.kobe_u.cs.prolog.lang.Term)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

compareTo

public int compareTo(Term anotherTerm)
Compares two terms in Prolog standard order of terms.
It is noted that t1.compareTo(t2) == 0 has the same boolean value as t1.equals(t2).

Parameters:
anotherTerm - the term to compared with. It must be dereferenced.
Returns:
the value 0 if two terms are identical; a value less than 0 if this term is before the anotherTerm; and a value greater than 0 if this term is after the anotherTerm.

intValue

public int intValue()
Description copied from class: NumberTerm
Returns the numeric value represented by this object after conversion to type int.

Specified by:
intValue in class NumberTerm

longValue

public long longValue()
Description copied from class: NumberTerm
Returns the numeric value represented by this object after conversion to type long.

Specified by:
longValue in class NumberTerm

doubleValue

public double doubleValue()
Description copied from class: NumberTerm
Returns the numeric value represented by this object after conversion to type double.

Specified by:
doubleValue in class NumberTerm

arithCompareTo

public int arithCompareTo(NumberTerm t)
Description copied from class: NumberTerm
Compares two NumberTerm objects numerically.

Specified by:
arithCompareTo in class NumberTerm
Parameters:
t - the NumberTerm to compare with.
Returns:
the value 0 if this object is numerically equal to the argument NumberTerm; a value less than 0 if this object is numerically less than the argument NumberTerm; and a value greater than 0 if this object is numerically greater than the argument NumberTerm.

abs

public NumberTerm abs()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is abs(this).

Specified by:
abs in class NumberTerm

acos

public NumberTerm acos()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is acos(this).

Specified by:
acos in class NumberTerm

add

public NumberTerm add(NumberTerm t)
Description copied from class: NumberTerm
Returns a NumberTerm whose value is (this + t).

Specified by:
add in class NumberTerm

and

public NumberTerm and(NumberTerm t)
Description copied from class: NumberTerm
Returns a NumberTerm whose value is (this & t).

Specified by:
and in class NumberTerm
Throws:
IllegalTypeException - if the given argument NumberTerm is a floating point number.

asin

public NumberTerm asin()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is asin(this).

Specified by:
asin in class NumberTerm

atan

public NumberTerm atan()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is tan(this).

Specified by:
atan in class NumberTerm

ceil

public NumberTerm ceil()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is ceil(this).

Specified by:
ceil in class NumberTerm

cos

public NumberTerm cos()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is cos(this).

Specified by:
cos in class NumberTerm

divide

public NumberTerm divide(NumberTerm t)
Description copied from class: NumberTerm
Returns a NumberTerm whose value is (this / t).

Specified by:
divide in class NumberTerm
Throws:
EvaluationException - if the given argument NumberTerm represents 0.

exp

public NumberTerm exp()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is exp(this).

Specified by:
exp in class NumberTerm

floatIntPart

public NumberTerm floatIntPart()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is the float-integer-part of this.

Specified by:
floatIntPart in class NumberTerm

floatFractPart

public NumberTerm floatFractPart()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is the float-fractional-part of this.

Specified by:
floatFractPart in class NumberTerm

floor

public NumberTerm floor()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is floor(this).

Specified by:
floor in class NumberTerm

intDivide

public NumberTerm intDivide(NumberTerm t)
Description copied from class: NumberTerm
Returns a NumberTerm whose value is (int)(this / t).

Specified by:
intDivide in class NumberTerm
Throws:
IllegalTypeException - if the given argument NumberTerm is a floating point number.
EvaluationException - if the given argument NumberTerm represents 0.

log

public NumberTerm log()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is log(this).

Specified by:
log in class NumberTerm
Throws:
EvaluationException - if this object represents 0.

max

public NumberTerm max(NumberTerm t)
Description copied from class: NumberTerm
Returns a NumberTerm whose value is max(this, t).

Specified by:
max in class NumberTerm

min

public NumberTerm min(NumberTerm t)
Description copied from class: NumberTerm
Returns a NumberTerm whose value is min(this, t).

Specified by:
min in class NumberTerm

mod

public NumberTerm mod(NumberTerm t)
Description copied from class: NumberTerm
Returns a NumberTerm whose value is (this mod t).

Specified by:
mod in class NumberTerm
Throws:
IllegalTypeException - if the given argument NumberTerm is a floating point number.
EvaluationException - if the given argument NumberTerm represents 0.

multiply

public NumberTerm multiply(NumberTerm t)
Description copied from class: NumberTerm
Returns a NumberTerm whose value is (this * t).

Specified by:
multiply in class NumberTerm

negate

public NumberTerm negate()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is (- this).

Specified by:
negate in class NumberTerm

not

public NumberTerm not()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is (~ this).

Specified by:
not in class NumberTerm

or

public NumberTerm or(NumberTerm t)
Description copied from class: NumberTerm
Returns a NumberTerm whose value is (this | t).

Specified by:
or in class NumberTerm
Throws:
IllegalTypeException - if the given argument NumberTerm is a floating point number.

pow

public NumberTerm pow(NumberTerm t)
Description copied from class: NumberTerm
Returns a NumberTerm whose value is (thist).

Specified by:
pow in class NumberTerm

rint

public NumberTerm rint()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is rint(this).

Specified by:
rint in class NumberTerm

round

public NumberTerm round()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is round(this).

Specified by:
round in class NumberTerm

shiftLeft

public NumberTerm shiftLeft(NumberTerm t)
Description copied from class: NumberTerm
Returns a NumberTerm whose value is (this << t).

Specified by:
shiftLeft in class NumberTerm
Throws:
IllegalTypeException - if the given argument NumberTerm is a floating point number.

shiftRight

public NumberTerm shiftRight(NumberTerm t)
Description copied from class: NumberTerm
Returns a NumberTerm whose value is (this >> t).

Specified by:
shiftRight in class NumberTerm
Throws:
IllegalTypeException - if the given argument NumberTerm is a floating point number.

signum

public NumberTerm signum()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is signum(this).

Specified by:
signum in class NumberTerm

sin

public NumberTerm sin()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is sin(this).

Specified by:
sin in class NumberTerm

sqrt

public NumberTerm sqrt()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is sqrt(this).

Specified by:
sqrt in class NumberTerm
Throws:
EvaluationException - if this object represents an integer less than 0.

subtract

public NumberTerm subtract(NumberTerm t)
Description copied from class: NumberTerm
Returns a NumberTerm whose value is (this - t).

Specified by:
subtract in class NumberTerm

tan

public NumberTerm tan()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is tan(this).

Specified by:
tan in class NumberTerm

toDegrees

public NumberTerm toDegrees()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is toDegrees(this).

Specified by:
toDegrees in class NumberTerm

toFloat

public NumberTerm toFloat()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is (double)(this).

Specified by:
toFloat in class NumberTerm

toRadians

public NumberTerm toRadians()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is toRadians(this).

Specified by:
toRadians in class NumberTerm

truncate

public NumberTerm truncate()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is the truncate of this.

Specified by:
truncate in class NumberTerm

xor

public NumberTerm xor(NumberTerm t)
Description copied from class: NumberTerm
Returns a NumberTerm whose value is (this ^ t).

Specified by:
xor in class NumberTerm
Throws:
IllegalTypeException - if the given argument NumberTerm is a floating point number.

Prolog Cafe v1.2

Copyright (C) 1997-2008 M.BANBARA and N.TAMURA