|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jboss.dna.common.math.IntegerOperations
@Immutable public class IntegerOperations

The math operations for integer numbers.
| Constructor Summary | |
|---|---|
IntegerOperations()
|
|
| Method Summary | |
|---|---|
Integer |
add(Integer value1,
Integer value2)
Add the two operands and return the sum. |
BigDecimal |
asBigDecimal(Integer value)
Create a BigDecimal representation of the supplied value. |
int |
compare(Integer value1,
Integer value2)
Compare the two operands and return an integer that describes whether the first value is larger, smaller or the same as the second value. |
Integer |
create(double value)
Convert the double representation into the natural object representation. |
Integer |
create(int value)
Convert the integer representation into the natural object representation. |
Integer |
create(long value)
Convert the long representation into the natural object representation. |
Integer |
createZeroValue()
Create the object form of the "zero value". |
double |
divide(Integer value1,
Integer value2)
Divide the first operand by the second, and return the result. |
double |
doubleValue(Integer value)
Convert the value to a double. |
float |
floatValue(Integer value)
Convert the value to a float. |
Integer |
fromBigDecimal(BigDecimal value)
Convert the BigDecimal representation into the natural object representation. |
Comparator<Integer> |
getComparator()
Return a Comparator for this operand class. |
int |
getExponentInScientificNotation(Integer value)
Get the exponent if the number were written in exponential form. |
Class<Integer> |
getOperandClass()
Return the class that these operations operate upon. |
Integer |
increment(Integer value)
Increment the supplied operand by 1. |
int |
intValue(Integer value)
Convert the value to an integer. |
Integer |
keepSignificantFigures(Integer value,
int numSigFigs)
|
long |
longValue(Integer value)
Convert the value to a long integer. |
Integer |
maximum(Integer value1,
Integer value2)
Compare the two operands and return the one that is larger. |
Integer |
minimum(Integer value1,
Integer value2)
Compare the two operands and return the one that is smaller. |
Integer |
multiply(Integer value1,
Integer value2)
Multiply the two operands and return the product. |
Integer |
negate(Integer value)
Negate the supplied operand. |
Integer |
random(Integer minimum,
Integer maximum,
Random rng)
Generate a random instance within the specified range. |
Integer |
roundDown(Integer value,
int decimalShift)
Round down the supplied value to the desired scale. |
Integer |
roundUp(Integer value,
int decimalShift)
Round up the supplied value to the desired scale. |
short |
shortValue(Integer value)
Convert the value to a short. |
double |
sqrt(Integer value)
Return the square root of the supplied operand. |
Integer |
subtract(Integer value1,
Integer value2)
Subtract the second operand from the first, and return the difference. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Comparator |
|---|
equals |
| Constructor Detail |
|---|
public IntegerOperations()
| Method Detail |
|---|
public Class<Integer> getOperandClass()
MathOperations
getOperandClass in interface MathOperations<Integer>
public Integer add(Integer value1,
Integer value2)
MathOperationszero value is used in place of any operand that is
null.
add in interface MathOperations<Integer>value1 - the first operandvalue2 - the second operand
public Integer subtract(Integer value1,
Integer value2)
MathOperationszero value is used in
place of any operand that is null.
subtract in interface MathOperations<Integer>value1 - the first operandvalue2 - the second operand
public Integer multiply(Integer value1,
Integer value2)
MathOperationszero value is used in place of any operand
that is null.
multiply in interface MathOperations<Integer>value1 - the first operandvalue2 - the second operand
public double divide(Integer value1,
Integer value2)
MathOperationszero value is used in place
of any operand that is null.
divide in interface MathOperations<Integer>value1 - the first operandvalue2 - the second operand
public Integer negate(Integer value)
MathOperationszero value is used in place of any operand that is null.
negate in interface MathOperations<Integer>value - the value that is to be negated
public Integer increment(Integer value)
MathOperationsoperand class. The zero value is used in place of any operand that is
null.
increment in interface MathOperations<Integer>value - the value that is to be incremented
public Integer maximum(Integer value1,
Integer value2)
MathOperations
maximum in interface MathOperations<Integer>value1 - the first operandvalue2 - the second operand
public Integer minimum(Integer value1,
Integer value2)
MathOperations
minimum in interface MathOperations<Integer>value1 - the first operandvalue2 - the second operand
public int compare(Integer value1,
Integer value2)
MathOperationsComparable. The zero value is used
in place of any operand that is null.
compare in interface Comparator<Integer>compare in interface MathOperations<Integer>value1 - the first operandvalue2 - the second operand
public BigDecimal asBigDecimal(Integer value)
MathOperationsBigDecimal representation of the supplied value.
asBigDecimal in interface MathOperations<Integer>value - the value that is to be converted to a BigDecimal
value is nullpublic Integer fromBigDecimal(BigDecimal value)
MathOperationsBigDecimal representation into the natural object representation. This may result in loss of some data
(e.g., converting a decimal to an integer results in the loss of the fractional part of the number).
fromBigDecimal in interface MathOperations<Integer>value - the BigDecimal value
value is nullpublic Integer createZeroValue()
MathOperations
createZeroValue in interface MathOperations<Integer>public Integer create(int value)
MathOperations
create in interface MathOperations<Integer>value - the integer value
public Integer create(long value)
MathOperations
create in interface MathOperations<Integer>value - the long value
public Integer create(double value)
MathOperations
create in interface MathOperations<Integer>value - the double value
public double sqrt(Integer value)
MathOperations
sqrt in interface MathOperations<Integer>value - the value whose root is to be found; may not be null or 0
public Comparator<Integer> getComparator()
MathOperationsComparator for this operand class. The implementation is free to
return the same comparator instance from multiple invocations of this method.
getComparator in interface MathOperations<Integer>
public Integer random(Integer minimum,
Integer maximum,
Random rng)
MathOperations
random in interface MathOperations<Integer>minimum - the minimum value, or null if the zero-value should be used for the minimummaximum - the maximum value, or null if the zero-value should be used for the maximumrng - the random number generator to use
operand class placed within the desired range using a random
distribution, or null if this class does not support generating random instancespublic double doubleValue(Integer value)
MathOperationsoperand class.
doubleValue in interface MathOperations<Integer>value - the value
public float floatValue(Integer value)
MathOperationsoperand
class.
floatValue in interface MathOperations<Integer>value - the value
public int intValue(Integer value)
MathOperationsoperand class.
intValue in interface MathOperations<Integer>value - the value
public long longValue(Integer value)
MathOperationsoperand class.
longValue in interface MathOperations<Integer>value - the value
public short shortValue(Integer value)
MathOperationsoperand
class.
shortValue in interface MathOperations<Integer>value - the value
public int getExponentInScientificNotation(Integer value)
MathOperations
getExponentInScientificNotation in interface MathOperations<Integer>value - the value
public Integer roundUp(Integer value,
int decimalShift)
MathOperationsdecimalShift places, rounding, and then shifting the decimal point of the rounded value by
-decimalShift
For example, consider the number 10.000354. This can be rounded to 10.0004 by calling this method and supplying the value and an "exponentToKeep" value of -4.
roundUp in interface MathOperations<Integer>value - the value to be roundeddecimalShift - the number of places the decimal point should be shifted before rounding
public Integer roundDown(Integer value,
int decimalShift)
MathOperationsdecimalShift places, rounding, and then shifting the decimal point of the rounded value by
-decimalShift
For example, consider the number 10.000354. This can be rounded to 10.0003 by calling this method and supplying the value and an "exponentToKeep" value of -4.
roundDown in interface MathOperations<Integer>value - the value to be roundeddecimalShift - the number of places the decimal point should be shifted before rounding
public Integer keepSignificantFigures(Integer value,
int numSigFigs)
keepSignificantFigures in interface MathOperations<Integer>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||