ariba.util.core
Class Arithmetic

java.lang.Object
  extended by ariba.util.core.Arithmetic

public abstract class Arithmetic
extends java.lang.Object

Arithmetic is an abstract class that encapsulates the idea of doing simple arithmetic operations on instances of the sub-types of java.lang.Number.

For example: 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

ByteType

public static final int ByteType
Represents the Byte type.

See Also:
Constant Field Values

ShortType

public static final int ShortType
Represents the Short type.

See Also:
Constant Field Values

IntegerType

public static final int IntegerType
Represents the Integer type.

See Also:
Constant Field Values

LongType

public static final int LongType
Represents the Long type.

See Also:
Constant Field Values

FloatType

public static final int FloatType
Represents the Float type.

See Also:
Constant Field Values

DoubleType

public static final int DoubleType
Represents the Double type.

See Also:
Constant Field Values

BigIntegerType

public static final int BigIntegerType
Represents the BigInteger type.

See Also:
Constant Field Values

BigDecimalType

public static final int BigDecimalType
Represents the BigDecimal type.

See Also:
Constant Field Values

IntegerArithmetic

public static final Arithmetic IntegerArithmetic

LongArithmetic

public static final Arithmetic LongArithmetic

DoubleArithmetic

public static final Arithmetic DoubleArithmetic

BigIntegerArithmetic

public static final Arithmetic BigIntegerArithmetic

BigDecimalArithmetic

public static final Arithmetic BigDecimalArithmetic
Constructor Detail

Arithmetic

public Arithmetic()
Method Detail

add

public abstract java.lang.Number add(java.lang.Number first,
                                     java.lang.Number second)
Adds first and second and returns the result.


subtract

public abstract java.lang.Number subtract(java.lang.Number first,
                                          java.lang.Number second)
Subtracts second from first and returns the result.


multiply

public abstract java.lang.Number multiply(java.lang.Number first,
                                          java.lang.Number second)
Multiplies first by second and returns the result.


divide

public abstract java.lang.Number divide(java.lang.Number first,
                                        java.lang.Number second)
Divides first by second and returns the result.


compare

public abstract int compare(java.lang.Number first,
                            java.lang.Number second)
Compares first and second and returns the result.


evaluate

public final 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.


asBigInteger

public static java.math.BigInteger asBigInteger(java.lang.Number number)

asBigDecimal

public static java.math.BigDecimal asBigDecimal(java.lang.Number number)

getNumberType

public static int getNumberType(java.lang.Number number)
Returns one of the constants representing


getArithmeticFromNumberType

public static Arithmetic getArithmeticFromNumberType(int numberType)
Returns the Arithmetic instance corresponding to the supplied numberType.


negate

public static java.lang.Number negate(java.lang.Number number)


AribaWeb User Interface Development Framework
Copyright © 2000-2014 Ariba, Inc. All Rights Reserved.