|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.logikdev.jsftools.StaticMathTool
public class StaticMathTool
Tool for performing math in JSF.
Constructor Summary | |
---|---|
StaticMathTool()
|
Method Summary | |
---|---|
static java.lang.Number |
abs(java.lang.Object num)
Returns the absolute value of the number or null if it's invalid. |
static java.lang.Number |
add(java.lang.Object[] nums)
Returns the sum of the numbers or null if they're invalid. |
static java.lang.Number |
add(java.lang.Object num1,
java.lang.Object num2)
Returns the sum of the two numbers or null if they're invalid. |
static java.lang.Integer |
ceil(java.lang.Object num)
Returns the smallest integer that is not less than the given number. |
static java.lang.Number |
div(java.lang.Object[] nums)
Returns the quotient of the numbers or null if they're invalid or if any denominator equals zero. |
static java.lang.Number |
div(java.lang.Object num1,
java.lang.Object num2)
Returns the quotient of the two numbers or null if they're invalid or if any denominator equals zero. |
static java.lang.Integer |
floor(java.lang.Object num)
Returns the integer portion of the number. |
static java.lang.Number |
getAverage(java.util.Collection<?> collection)
Gets the average of the values. |
static java.lang.Number |
getAverage(java.util.Collection<?> collection,
java.lang.String field)
Gets the average of the values from a list. |
static java.lang.Number |
getAverage(java.lang.Double[] values)
Gets the average of the values in an array of double values. |
static java.lang.Number |
getAverage(java.lang.Long[] values)
Gets the average of the values in an array of long values. |
static java.lang.Number |
getAverage(java.lang.Object[] array)
Gets the average of the values. |
static java.lang.Number |
getAverage(java.lang.Object[] array,
java.lang.String field)
Get the average of the values from a list. |
static java.lang.Double |
getRandom()
Returns a pseudo-random Double greater than or equal to 0.0 and less than 1.0. |
static java.lang.Number |
getTotal(java.util.Collection<?> collection)
Gets the sum of the values. |
static java.lang.Number |
getTotal(java.util.Collection<?> collection,
java.lang.String field)
Gets the sum of the values from a list. |
static java.lang.Number |
getTotal(java.lang.Double[] values)
Gets the sum of the values. |
static java.lang.Number |
getTotal(java.lang.Long[] values)
Gets the sum of the values. |
static java.lang.Number |
getTotal(java.lang.Object[] array)
Gets the sum of the values. |
static java.lang.Number |
getTotal(java.lang.Object[] array,
java.lang.String field)
Gets the sum of the values from a list. |
static java.lang.Integer |
idiv(java.lang.Object num1,
java.lang.Object num2)
Does integer division on the int values of the specified numbers. |
static java.lang.Number |
max(java.lang.Object[] nums)
Returns the largest of the numbers or null if they're invalid. |
static java.lang.Number |
max(java.lang.Object num1,
java.lang.Object num2)
Returns the largest of the two numbers or null if they're invalid. |
static java.lang.Number |
min(java.lang.Object[] nums)
Returns the smallest of the numbers or null if they're invalid. |
static java.lang.Number |
min(java.lang.Object num1,
java.lang.Object num2)
Returns the smallest of the numbers or null if they're invalid. |
static java.lang.Integer |
mod(java.lang.Object num1,
java.lang.Object num2)
Does integer modulus on the int values of the specified numbers. |
static java.lang.Number |
mul(java.lang.Object[] nums)
Returns the product of the numbers or null if they're invalid. |
static java.lang.Number |
mul(java.lang.Object num1,
java.lang.Object num2)
Returns the product of the two numbers or null if they're invalid. |
static java.lang.Number |
pow(java.lang.Object num1,
java.lang.Object num2)
Returns the first number raised to the power of the second or null if they're invalid. |
static java.lang.Number |
random(java.lang.Object num1,
java.lang.Object num2)
This returns a random Number within the specified range. |
static java.lang.Integer |
round(java.lang.Object num)
Rounds a number to the nearest whole Integer. |
static java.lang.Double |
roundTo(java.lang.Object decimals,
java.lang.Object num)
Rounds a number to the specified number of decimal places. |
static java.lang.Number |
sub(java.lang.Object[] nums)
Returns the difference of the numbers (subtracted in order) or null if they're invalid. |
static java.lang.Number |
sub(java.lang.Object num1,
java.lang.Object num2)
Returns the difference of the two numbers (subtracted in order) or null if they're invalid. |
static java.lang.Double |
toDouble(java.lang.Object num)
Converts an object with a numeric value into a Double Valid formats are Number or a String representation of a number. |
static java.lang.Integer |
toInteger(java.lang.Object num)
Converts an object with a numeric value into an Integer Valid formats are Number or a String representation of a number. |
static java.lang.Number |
toNumber(java.lang.Object num)
Converts an object with a numeric value into a Number Valid formats are Number or a String representation of a number. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StaticMathTool()
Method Detail |
---|
public static final java.lang.Number abs(java.lang.Object num)
null
if it's invalid.
num
- The number
null
if it's invalidpublic static final java.lang.Number add(java.lang.Object[] nums)
null
if they're invalid.
nums
- The numbers to be added
null
if they're invalidpublic static final java.lang.Number add(java.lang.Object num1, java.lang.Object num2)
null
if they're invalid.
num1
- The first numbernum2
- The second number
null
if they're invalidpublic static final java.lang.Integer ceil(java.lang.Object num)
num
- The number
public static final java.lang.Number div(java.lang.Object[] nums)
null
if they're invalid or if any denominator equals zero.
nums
- The numbers to be divided
null
if they're invalid or if any denominator equals zeropublic static final java.lang.Number div(java.lang.Object num1, java.lang.Object num2)
null
if they're invalid or if any denominator equals zero.
num1
- The first numbernum2
- The second number
null
if they're invalid or if any denominator equals zeropublic static final java.lang.Integer floor(java.lang.Object num)
num
- The number
public static final java.lang.Number getAverage(java.util.Collection<?> collection)
collection
- A collection containing number values
public static final java.lang.Number getAverage(java.util.Collection<?> collection, java.lang.String field)
collection
- A collection containing Java beansfield
- A Java Bean field for the objects in collection that will return a number
public static final java.lang.Number getAverage(java.lang.Double[] values)
values
- The list of double values
public static final java.lang.Number getAverage(java.lang.Long[] values)
values
- The list of long values
public static final java.lang.Number getAverage(java.lang.Object[] array)
array
- An array containing number values
public static final java.lang.Number getAverage(java.lang.Object[] array, java.lang.String field)
array
- A collection containing Java beansfield
- A Java Bean field for the objects in array that will return a number
public static final java.lang.Double getRandom()
Double
greater than or equal to 0.0 and less than 1.0.
Double
greater than or equal to 0.0 and less than 1.0public static final java.lang.Number getTotal(java.util.Collection<?> collection)
collection
- A collection containing numeric values
public static final java.lang.Number getTotal(java.util.Collection<?> collection, java.lang.String field)
collection
- A collection containing Java beansfield
- A Java Bean field for the objects in collection that will return a number
public static final java.lang.Number getTotal(java.lang.Double[] values)
values
- The list of double values to add up
public static final java.lang.Number getTotal(java.lang.Long[] values)
values
- The list of long values to add up
public static final java.lang.Number getTotal(java.lang.Object[] array)
array
- An array containing number values
public static final java.lang.Number getTotal(java.lang.Object[] array, java.lang.String field)
array
- An array containing Java beansfield
- A Java Bean field for the objects in array that will return a number
public static final java.lang.Integer idiv(java.lang.Object num1, java.lang.Object num2)
num1
- The first numbernum2
- The second number
public static final java.lang.Number max(java.lang.Object[] nums)
null
if they're invalid.
nums
- The numbers to be searched
null
if they're invalidpublic static final java.lang.Number max(java.lang.Object num1, java.lang.Object num2)
null
if they're invalid.
num1
- The first numbernum2
- The second number
null
if they're invalidpublic static final java.lang.Number min(java.lang.Object[] nums)
null
if they're invalid.
nums
- The numbers to be searched
null
if they're invalidpublic static final java.lang.Number min(java.lang.Object num1, java.lang.Object num2)
null
if they're invalid.
num1
- The first numbernum2
- The second number
null
if they're invalidpublic static final java.lang.Integer mod(java.lang.Object num1, java.lang.Object num2)
num1
- The first numbernum2
- The second number
public static final java.lang.Number mul(java.lang.Object[] nums)
null
if they're invalid.
nums
- The numbers to be multiplied
null
if they're invalidpublic static final java.lang.Number mul(java.lang.Object num1, java.lang.Object num2)
null
if they're invalid.
num1
- The first numbernum2
- The second number
null
if they're invalidpublic static final java.lang.Number pow(java.lang.Object num1, java.lang.Object num2)
null
if they're invalid.
num1
- The first numbernum2
- The second number
null
if they're invalidpublic static final java.lang.Number random(java.lang.Object num1, java.lang.Object num2)
Number
within the specified range.
The returned value will be greater than or equal to the first number and less than the second number.
If both arguments are whole numbers then the returned number will also be, otherwise a Double
will be returned.
num1
- The first numbernum2
- The second number
Number
greater than or equal to the first number and less than the secondpublic static final java.lang.Integer round(java.lang.Object num)
num
- The number to round
null
if it's invalidpublic static final java.lang.Double roundTo(java.lang.Object decimals, java.lang.Object num)
Integer
rather than a Double.
decimals
- The number of decimal placesnum
- The number to round
null
if it's invalidpublic static final java.lang.Number sub(java.lang.Object[] nums)
null
if they're invalid.
nums
- The numbers to be subtracted
null
if they're invalidpublic static final java.lang.Number sub(java.lang.Object num1, java.lang.Object num2)
null
if they're invalid.
num1
- The first numbernum2
- The second number
null
if they're invalidpublic static final java.lang.Double toDouble(java.lang.Object num)
Number
or a String
representation of a number.
num
- The number to be converted
Double
representation of the number or null
if it's invalidpublic static final java.lang.Integer toInteger(java.lang.Object num)
Number
or a String
representation of a number.
num
- The number to be converted
Integer
representation of the number or null
if it's invalidpublic static final java.lang.Number toNumber(java.lang.Object num)
Number
or a String
representation of a number.
Note that this does not handle localized number formats.
Use the StaticNumberTool to handle such conversions.
num
- The number to be converted
Number
representation of the number or null
if it's invalid
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |