|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectau.gov.tas.dpiwe.mr.util.Numbers
public class Numbers
This class contains static utility methods to manipulate numbers of the standard Java immutable kind, primitive numeric types, mutable numbers of the Mr Architecture kind and NullableNumbers.
There is a reason why this class is used for output and type conversion only (and is therefore not symmetrical/ orthogonal)- the output methods are useful in the toolkit subpackage, and often users of the toolkit subpackage don't want to be dependent on J2EE, which is what would happen if we were to move those to PresentationUtilities where they really belong. Naturally, advanced stuff should be left to Ms Architecture.
| Field Summary | |
|---|---|
static BigDecimal |
Number_1000
A modest number. |
static BigDecimal |
Number_1E12
A huge number. |
static BigDecimal |
Number_1E15
A massive number. |
static BigDecimal |
Number_1E18
An enormous number. |
static BigDecimal |
Number_1E6
A large number. |
static BigDecimal |
Number_1E9
A great number. |
static BigDecimal |
Number_1EMinus12
A very tiny number. |
static BigDecimal |
Number_1EMinus15
A miniscule number. |
static BigDecimal |
Number_1EMinus18
An infinitesimal number. |
static BigDecimal |
Number_1EMinus3
A small number. |
static BigDecimal |
Number_1EMinus6
A very small number. |
static BigDecimal |
Number_1EMinus9
A tiny number. |
| Constructor Summary | |
|---|---|
Numbers()
|
|
| Method Summary | |
|---|---|
static NumberFormat |
applyMetaData(NumberFormat formatter,
TypedNumber number)
Takes the metadata supplied with a number and applies it to the given formatter. |
static TypedNumber |
applyMetaData(TypedNumber number,
MetaData.TypeRecord metaData)
Takes the metadata supplied and applies it to the given number. |
static byte |
byteValue(Number input)
Produces a primitive value. |
static double |
doubleValue(Number input)
Produces a primitive value. |
static String |
expressValue(NumberFormat formatter,
BigDecimal value,
int exponent)
Scales and expresses a value using the specified formatter. |
static String |
expressValue(NumberFormat formatter,
TypedNumber number)
Expresses a numeric value in the specified format, while obeying restrinctions on minimal and maximal places before and after the radix point. |
static String |
expressValue(TypedNumber number)
Expresses a numeric value in the default format, while obeying restrinctions on minimal and maximal places before and after the radix point. |
static String |
expressValueWithUnit(NumberFormat formatter,
TypedNumber number)
Expresses a numeric value with its unit in the specified format, while obeying restrinctions on minimal and maximal places before and after the radix point. |
static String |
expressValueWithUnit(TypedNumber number)
Expresses a numeric value with its unit in the default format, while obeying restrinctions on minimal and maximal places before and after the radix point. |
static float |
floatValue(Number input)
Produces a primitive value. |
static Number |
immutable(byte input)
Produces an immutable object wrapping the specified primitive value. |
static Number |
immutable(double input)
Produces an immutable object wrapping the specified primitive value. |
static Number |
immutable(float input)
Produces an immutable object wrapping the specified primitive value. |
static Number |
immutable(int input)
Produces an immutable object wrapping the specified primitive value. |
static Number |
immutable(long input)
Produces an immutable object wrapping the specified primitive value. |
static Number |
immutable(Number input)
Changes the specified number into an immutable object, where a corresponding immutable Number sublcass is known, otherwise the input is returned. |
static Number |
immutable(short input)
Produces an immutable object wrapping the specified primitive value. |
static Interval |
interval(Number input)
Changes the specified number into an Interval object, where a corresponding interval Number sublcass is known, otherwise an exception is thrown. |
static int |
intValue(Number input)
Produces a primitive value. |
static long |
longValue(Number input)
Produces a primitive value. |
static Number |
mutable(byte input)
Produces a mutable object wrapping the specified primitive value. |
static Number |
mutable(double input)
Produces a mutable object wrapping the specified primitive value. |
static Number |
mutable(float input)
Produces a mutable object wrapping the specified primitive value. |
static Number |
mutable(int input)
Produces a mutable object wrapping the specified primitive value. |
static Number |
mutable(long input)
Produces a mutable object wrapping the specified primitive value. |
static Number |
mutable(Number input)
Changes the specified number into an mutable object, where a corresponding mutable Number sublcass is known, otherwise the input is returned. |
static Number |
mutable(short input)
Produces a mutable object wrapping the specified primitive value. |
static Number |
reconcile(Number prototype,
Number value)
Produces a number with the specified type and value. |
static Interval |
setUpperBound(Interval throughput,
Number input)
Changes the specified interval, or returns a copy with the upper bound changed. |
static short |
shortValue(Number input)
Produces a primitive value. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final BigDecimal Number_1E18
public static final BigDecimal Number_1E15
public static final BigDecimal Number_1E12
public static final BigDecimal Number_1E9
public static final BigDecimal Number_1E6
public static final BigDecimal Number_1000
public static final BigDecimal Number_1EMinus3
public static final BigDecimal Number_1EMinus6
public static final BigDecimal Number_1EMinus9
public static final BigDecimal Number_1EMinus12
public static final BigDecimal Number_1EMinus15
public static final BigDecimal Number_1EMinus18
| Constructor Detail |
|---|
public Numbers()
| Method Detail |
|---|
public static Interval setUpperBound(Interval throughput,
Number input)
throughput - an interval, from which the
lower bound (at least) is preserved.input - the new upper bound for the interval.
public static Number immutable(Number input)
input - containing the value to make
an immutable number from.
public static Interval interval(Number input)
input - containing the value to make
an Interval from.
IllegalArgumentException - if the
input subtype is not recognised.public static Number immutable(byte input)
input - the value to make an immutable
object from.
public static Number immutable(short input)
input - the value to make an immutable
object from.
public static Number immutable(int input)
input - the value to make an immutable
object from.
public static Number immutable(long input)
input - the value to make an immutable
object from.
public static Number immutable(float input)
input - the value to make an immutable
object from.
public static Number immutable(double input)
input - the value to make an immutable
object from.
public static byte byteValue(Number input)
input - the value to make a byte
from.
public static short shortValue(Number input)
input - the value to make a short
from.
public static double doubleValue(Number input)
input - the value to make a double
from.
public static float floatValue(Number input)
input - the value to make a float
from.
public static long longValue(Number input)
input - the value to make a long
from.
public static int intValue(Number input)
input - the value to make an integer
from.
public static Number mutable(Number input)
number - containing the value to make
a mutable number from.
NullPointerException - if the number
represented by the input is null, or if input
is null.public static Number mutable(byte input)
input - the value to make a mutable
object from.
public static Number mutable(short input)
input - the value to make a mutable
object from.
public static Number mutable(int input)
input - the value to make a mutable
object from.
public static Number mutable(long input)
input - the value to make a mutable
object from.
public static Number mutable(float input)
input - the value to make a mutable
object from.
public static Number mutable(double input)
input - the value to make a mutable
object from.
public static Number reconcile(Number prototype,
Number value)
All the warnings to do with Java value promotion and demotion apply.
prototype - a number of the type to be
produced, which may not be null.value - the value to be assigned to the
produced number. If the value is null, then
a NullableNumber subclass is used to wrap
the value irrespective of the prototype
specified.
public static TypedNumber applyMetaData(TypedNumber number,
MetaData.TypeRecord metaData)
number - the number whose type information is to be changed.metaData - the metadata describing the new type information.
public static NumberFormat applyMetaData(NumberFormat formatter,
TypedNumber number)
formatter - the formatter whose formatting parameters are to be changed.number - the number describing the new formatting parameters.public static String expressValueWithUnit(TypedNumber number)
number - the number to be expressed.
NullPointerException - if this value has no units.
public static String expressValueWithUnit(NumberFormat formatter,
TypedNumber number)
formatter - the object through which formatting will be achieved.number - the number to be expressed.
NullPointerException - if this value has no units.public static String expressValue(TypedNumber number)
number - the number to be expressed.
NullPointerException - if this value has no units.
public static String expressValue(NumberFormat formatter,
TypedNumber number)
formatter - the object through which formatting will be achieved.number - the number to be expressed.
NullPointerException - if this value has no units.
public static String expressValue(NumberFormat formatter,
BigDecimal value,
int exponent)
formatter - the object through which formatting will be achieved.value - the decimal to be expressed.exponent - the power of ten to scale by.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||