jpl

Class Integer

public class Integer extends Term

Integer is a specialised Term with a long field, representing a Prolog integer value.
 Integer i = new Integer(1024);
 
Once constructed, the value of an Integer instance cannot be altered. An Integer can be used (and re-used) as an argument of Compounds. Beware confusing jpl.Integer with java.lang.Integer.
Copyright (C) 2004 Paul Singleton

Copyright (C) 1998 Fred Dushin

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library Public License for more details.


See Also: Term Compound

Constructor Summary
Integer(long value)
Method Summary
Term[]args()
The (nonexistent) args of this Integer
intarity()
Returns the arity (0) of this jpl.Integer (c.f. functor/3)
StringdebugString()
Returns a debug-friendly representation of this Integer's value
doubledoubleValue()
Returns the value of this Integer converted to a double
booleanequals(Object obj)
Two Integer instances are equal if they are the same object, or if their values are equal
floatfloatValue()
Returns the value of this Integer converted to a float
booleanhasFunctor(int val, int arity)
Tests whether this Integer's functor has (int) 'name' and 'arity' (c.f. functor/3)
intintValue()
Returns the value of this Integer as an int if possible, else throws a JPLException
longlongValue()
Returns the value of this Integer as a long
Stringname()
throws a JPLException (name() is defined only for Compound, Atom and Variable)
StringtoString()
Returns a Prolog source text representation of this Integer's value
inttype()
StringtypeName()
intvalue()
Returns the int value of this jpl.Integer

Constructor Detail

Integer

public Integer(long value)

Parameters: value This Integer's (long) value

Method Detail

args

public Term[] args()
The (nonexistent) args of this Integer

Returns: the (nonexistent) args of this Integer

arity

public final int arity()
Returns the arity (0) of this jpl.Integer (c.f. functor/3)

Returns: the arity (0) of this jpl.Integer

debugString

public String debugString()

Deprecated:

Returns a debug-friendly representation of this Integer's value

Returns: a debug-friendly representation of this Integer's value

doubleValue

public final double doubleValue()
Returns the value of this Integer converted to a double

Returns: the value of this Integer converted to a double

equals

public final boolean equals(Object obj)
Two Integer instances are equal if they are the same object, or if their values are equal

Parameters: obj The Object to compare (not necessarily an Integer)

Returns: true if the Object satisfies the above condition

floatValue

public final float floatValue()
Returns the value of this Integer converted to a float

Returns: the value of this Integer converted to a float

hasFunctor

public final boolean hasFunctor(int val, int arity)
Tests whether this Integer's functor has (int) 'name' and 'arity' (c.f. functor/3)

Returns: whether this Integer's functor has (int) 'name' and 'arity'

intValue

public final int intValue()
Returns the value of this Integer as an int if possible, else throws a JPLException

Returns: the int value of this Integer

Throws: JPLException if the value of this Integer is too great to be represented as a Java int

longValue

public final long longValue()
Returns the value of this Integer as a long

Returns: the value of this Integer as a long

name

public final String name()
throws a JPLException (name() is defined only for Compound, Atom and Variable)

Returns: the name of this Integer (never)

toString

public String toString()
Returns a Prolog source text representation of this Integer's value

Returns: a Prolog source text representation of this Integer's value

type

public final int type()

typeName

public String typeName()

value

public final int value()

Deprecated:

Returns the int value of this jpl.Integer

Returns: the Integer's value