Top Description Fields Constructors Methods
tech.uom.lib.common.util

public Class NumberComparator

extends Object
implements Comparator<Number>
Class Inheritance
All Implemented Interfaces
java.util.Comparator
Static Imports
java.lang.Character.isDigit, .Character.isSpaceChar

Compares two Number objects with each other
Author
Werner
Since
1.0.2
Version
1.0

Field Summary

Modifier and TypeField and Description
private static NumberComparator

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected static char
charAt(String s, int i)

public int
compare(Number
the first object to be compared.
o1
,
Number
the second object to be compared.
o2
)

Implements java.util.Comparator.compare.

Compares its two arguments for order.

protected int
public static NumberComparator
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

instanceback to summary
private static NumberComparator instance

Constructor Detail

NumberComparatorback to summary
private NumberComparator()

Method Detail

charAtback to summary
protected static char charAt(String s, int i)
compareback to summary
public int compare(Number o1, Number o2)

Implements java.util.Comparator.compare.

Doc from java.util.Comparator.compare.

Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

The implementor must ensure that signum(compare(x, y)) == -signum(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that signum(compare(x, z))==signum(compare(y, z)) for all z.

Parameters
o1:Number

the first object to be compared.

o2:Number

the second object to be compared.

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

compareRightback to summary
protected int compareRight(String a, String b)
getInstanceback to summary
public static NumberComparator getInstance()