org.hecl
Class NumberThing
- java.lang.Object
-
- org.hecl.NumberThing
-
- All Implemented Interfaces:
- RealThing
- Direct Known Subclasses:
- FractionalThing, IntegralThing
public abstract class NumberThing extends java.lang.Object implements RealThing
TheNumberThingclass is what all numeric Thing types are derived from.
-
-
Constructor Summary
Constructors Constructor and Description NumberThing()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description static NumberThingasNumber(Thing t)asNumberattempts to transform Thing t into a number of some sort.abstract bytebyteValue()byteValuereturns the number as a byte.static Thingcreate(NumberThing n)Thecreatemethod creates a new Thing from NumberThing n.abstract RealThingdeepcopy()Thedeepcopymethod must copy a RealThing and any values it contains.abstract doubledoubleValue()doubleValuereturns the value as a double.abstract floatfloatValue()floatValuereturns the value as a float.abstract java.lang.StringgetStringRep()ThegetStringRepmethod returns the string representation of aRealThing.abstract intintValue()intValuereturns the number as an int.abstract booleanisFractional()static booleanisFractional(Thing t)isFractionalreturns true if Thing t is a fractional (floating point) number, false if it isn't.abstract booleanisIntegral()static booleanisIntegral(Thing t)isIntegralreturns true if Thing t is a whole number (an int or long), or false if it isn't.static booleanisNumber(RealThing rt)static booleanisNumber(Thing t)isNumberreturns true if Thing t is represented as a number internally.abstract longlongValue()longValuereturns the value as a long.abstract shortshortValue()shortValuereturns the number as a short.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hecl.RealThing
thingclass
-
-
-
-
Method Detail
-
deepcopy
public abstract RealThing deepcopy() throws HeclException
Description copied from interface:RealThingThedeepcopymethod must copy a RealThing and any values it contains.- Specified by:
deepcopyin interfaceRealThing- Returns:
- a
RealThingvalue - Throws:
HeclException
-
getStringRep
public abstract java.lang.String getStringRep()
Description copied from interface:RealThingThegetStringRepmethod returns the string representation of aRealThing.- Specified by:
getStringRepin interfaceRealThing- Returns:
- a
Stringrepresentation of the value
-
isNumber
public static boolean isNumber(Thing t)
isNumberreturns true if Thing t is represented as a number internally.- Parameters:
t- aThingvalue- Returns:
- a
booleanvalue
-
isNumber
public static boolean isNumber(RealThing rt)
-
isIntegral
public static boolean isIntegral(Thing t)
isIntegralreturns true if Thing t is a whole number (an int or long), or false if it isn't.- Parameters:
t- aThingvalue- Returns:
- a
booleanvalue
-
isFractional
public static boolean isFractional(Thing t)
isFractionalreturns true if Thing t is a fractional (floating point) number, false if it isn't.- Parameters:
t- aThingvalue- Returns:
- a
booleanvalue
-
isIntegral
public abstract boolean isIntegral()
-
isFractional
public abstract boolean isFractional()
-
byteValue
public abstract byte byteValue()
byteValuereturns the number as a byte.- Returns:
- a
bytevalue
-
shortValue
public abstract short shortValue()
shortValuereturns the number as a short.- Returns:
- a
shortvalue
-
intValue
public abstract int intValue()
intValuereturns the number as an int.- Returns:
- an
intvalue
-
longValue
public abstract long longValue()
longValuereturns the value as a long.- Returns:
- a
longvalue
-
floatValue
public abstract float floatValue()
floatValuereturns the value as a float. Not available in CLDC 1.0- Returns:
- a
floatvalue
-
doubleValue
public abstract double doubleValue()
doubleValuereturns the value as a double. Not available in CLDC 1.0- Returns:
- a
doublevalue
-
asNumber
public static NumberThing asNumber(Thing t) throws java.lang.NumberFormatException
asNumberattempts to transform Thing t into a number of some sort. It first tries to get an int from t, then a long, and finally a double.- Parameters:
t- aThingvalue- Returns:
- a
NumberThingvalue - Throws:
java.lang.NumberFormatException- when argument does not adhere to number format syntax.
-
create
public static Thing create(NumberThing n)
Thecreatemethod creates a new Thing from NumberThing n.- Parameters:
n- aNumberThingvalue- Returns:
- a
Thingvalue
-
-
DataMelt 3.0 © DataMelt by jWork.ORG