org.hecl
Class IntThing

java.lang.Object
  extended by org.hecl.NumberThing
      extended by org.hecl.IntegralThing
          extended by org.hecl.IntThing
All Implemented Interfaces:
RealThing

public class IntThing
extends IntegralThing

The IntThing class represents an integer Thing.

Version:
1.0
Author:
Wolfgang S. Kechel

Field Summary
static IntThing NEGONE
           
static IntThing ONE
           
static IntThing ZERO
           
 
Constructor Summary
IntThing()
          Creates a new IntThing instance equal to 0.
IntThing(boolean b)
          Creates a new IntThing instance from boolean b where true is 1 and false is 0.
IntThing(int i)
          Creates a new IntThing instance with value i.
IntThing(java.lang.String s)
          Creates a new IntThing instance from string s.
 
Method Summary
 byte byteValue()
          byteValue returns the number as a byte.
static Thing create(boolean b)
          The create method creates and returns a newly allocated Thing with an IntThing internal representation.
static Thing create(int i)
          The create method creates and returns a newly allocated Thing with an IntThing internal representation.
 RealThing deepcopy()
          deepcopy makes a copy.
 double doubleValue()
          doubleValue returns the value as a double.
 float floatValue()
          floatValue returns the value as a float.
static int get(Thing thing)
          get attempts to fetch an integer value from a Thing.
 java.lang.String getStringRep()
          getStringRep creates a string representation of the IntThing.
 int intValue()
          intValue returns the number as an int.
 long longValue()
          longValue returns the value as a long.
 void set(int i)
          set sets the internal value of an IntThing to i.
 short shortValue()
          shortValue returns the number as a short.
 java.lang.String thingclass()
           
 
Methods inherited from class org.hecl.IntegralThing
isFractional, isIntegral, isLong
 
Methods inherited from class org.hecl.NumberThing
asNumber, create, isFractional, isIntegral, isNumber, isNumber
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ZERO

public static IntThing ZERO

ONE

public static IntThing ONE

NEGONE

public static IntThing NEGONE
Constructor Detail

IntThing

public IntThing()
Creates a new IntThing instance equal to 0.


IntThing

public IntThing(int i)
Creates a new IntThing instance with value i.

Parameters:
i - an int value

IntThing

public IntThing(boolean b)
Creates a new IntThing instance from boolean b where true is 1 and false is 0.

Parameters:
b - a boolean value

IntThing

public IntThing(java.lang.String s)
Creates a new IntThing instance from string s.

Parameters:
s - a String value
Method Detail

thingclass

public java.lang.String thingclass()

create

public static Thing create(int i)
The create method creates and returns a newly allocated Thing with an IntThing internal representation.

Parameters:
i - an int value
Returns:
a Thing value

create

public static Thing create(boolean b)
The create method creates and returns a newly allocated Thing with an IntThing internal representation.

Parameters:
b - an boolean value
Returns:
a Thing value

get

public static int get(Thing thing)
               throws HeclException
get attempts to fetch an integer value from a Thing.

Parameters:
thing - a Thing value
Returns:
an int value
Throws:
HeclException - if an error occurs

byteValue

public byte byteValue()
Description copied from class: NumberThing
byteValue returns the number as a byte.

Specified by:
byteValue in class NumberThing
Returns:
a byte value

shortValue

public short shortValue()
Description copied from class: NumberThing
shortValue returns the number as a short.

Specified by:
shortValue in class NumberThing
Returns:
a short value

intValue

public int intValue()
Description copied from class: NumberThing
intValue returns the number as an int.

Specified by:
intValue in class NumberThing
Returns:
an int value

longValue

public long longValue()
Description copied from class: NumberThing
longValue returns the value as a long.

Specified by:
longValue in class NumberThing
Returns:
a long value

floatValue

public float floatValue()
Description copied from class: NumberThing
floatValue returns the value as a float. Not available in CLDC 1.0

Specified by:
floatValue in class NumberThing
Returns:
a float value

doubleValue

public double doubleValue()
Description copied from class: NumberThing
doubleValue returns the value as a double. Not available in CLDC 1.0

Specified by:
doubleValue in class NumberThing
Returns:
a double value

set

public void set(int i)
set sets the internal value of an IntThing to i.

Parameters:
i - an int value

deepcopy

public RealThing deepcopy()
deepcopy makes a copy.

Specified by:
deepcopy in interface RealThing
Specified by:
deepcopy in class NumberThing
Returns:
a RealThing value

getStringRep

public java.lang.String getStringRep()
getStringRep creates a string representation of the IntThing.

Specified by:
getStringRep in interface RealThing
Specified by:
getStringRep in class NumberThing
Returns:
a String value