|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectariba.util.core.Arithmetic
public abstract class Arithmetic
Arithmetic is an abstract class that encapsulates the idea of doing simple
arithmetic operations on instances of the sub-types of
java.lang.Number
.
IntegerArithmetic
does integer arithmetic on the
Numbers
passed to it via the Number.intValue()
method.
Nested Class Summary | |
---|---|
static class |
Arithmetic.Operation
Enumeration class capturing binary operations on instances of java.lang.Number . |
Field Summary | |
---|---|
static Arithmetic |
BigDecimalArithmetic
|
static int |
BigDecimalType
Represents the BigDecimal type. |
static Arithmetic |
BigIntegerArithmetic
|
static int |
BigIntegerType
Represents the BigInteger type. |
static int |
ByteType
Represents the Byte type. |
static Arithmetic |
DoubleArithmetic
|
static int |
DoubleType
Represents the Double type. |
static int |
FloatType
Represents the Float type. |
static Arithmetic |
IntegerArithmetic
|
static int |
IntegerType
Represents the Integer type. |
static Arithmetic |
LongArithmetic
|
static int |
LongType
Represents the Long type. |
static int |
ShortType
Represents the Short type. |
Constructor Summary | |
---|---|
Arithmetic()
|
Method Summary | |
---|---|
abstract java.lang.Number |
add(java.lang.Number first,
java.lang.Number second)
Adds first and second and returns the result. |
static java.math.BigDecimal |
asBigDecimal(java.lang.Number number)
|
static java.math.BigInteger |
asBigInteger(java.lang.Number number)
|
abstract int |
compare(java.lang.Number first,
java.lang.Number second)
Compares first and second and returns the result. |
abstract java.lang.Number |
divide(java.lang.Number first,
java.lang.Number second)
Divides first by second and returns the result. |
java.lang.Number |
evaluate(java.lang.Number first,
Arithmetic.Operation operation,
java.lang.Number second)
Evaluates first and second with respect to
operation which must be one of:
OpAdd, OpSubtract, OpMultiply, OpDivide . |
static Arithmetic |
getArithmeticFromNumberType(int numberType)
Returns the Arithmetic instance corresponding to the
supplied numberType . |
static int |
getNumberType(java.lang.Number number)
Returns one of the constants representing |
abstract java.lang.Number |
multiply(java.lang.Number first,
java.lang.Number second)
Multiplies first by second and returns the result. |
static java.lang.Number |
negate(java.lang.Number number)
|
abstract java.lang.Number |
subtract(java.lang.Number first,
java.lang.Number second)
Subtracts second from first and
returns the result. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int ByteType
Byte
type.
public static final int ShortType
Short
type.
public static final int IntegerType
Integer
type.
public static final int LongType
Long
type.
public static final int FloatType
Float
type.
public static final int DoubleType
Double
type.
public static final int BigIntegerType
BigInteger
type.
public static final int BigDecimalType
BigDecimal
type.
public static final Arithmetic IntegerArithmetic
public static final Arithmetic LongArithmetic
public static final Arithmetic DoubleArithmetic
public static final Arithmetic BigIntegerArithmetic
public static final Arithmetic BigDecimalArithmetic
Constructor Detail |
---|
public Arithmetic()
Method Detail |
---|
public abstract java.lang.Number add(java.lang.Number first, java.lang.Number second)
first
and second
and returns the result.
public abstract java.lang.Number subtract(java.lang.Number first, java.lang.Number second)
second
from first
and
returns the result.
public abstract java.lang.Number multiply(java.lang.Number first, java.lang.Number second)
first
by second
and returns the result.
public abstract java.lang.Number divide(java.lang.Number first, java.lang.Number second)
first
by second
and returns the result.
public abstract int compare(java.lang.Number first, java.lang.Number second)
first
and second
and returns the result.
public final java.lang.Number evaluate(java.lang.Number first, Arithmetic.Operation operation, java.lang.Number second)
first
and second
with respect to
operation
which must be one of:
OpAdd, OpSubtract, OpMultiply, OpDivide
.
public static java.math.BigInteger asBigInteger(java.lang.Number number)
public static java.math.BigDecimal asBigDecimal(java.lang.Number number)
public static int getNumberType(java.lang.Number number)
public static Arithmetic getArithmeticFromNumberType(int numberType)
Arithmetic
instance corresponding to the
supplied numberType
.
public static java.lang.Number negate(java.lang.Number number)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |