JIDE 3.5.15

com.jidesoft.comparator
Class NumberComparator

java.lang.Object
  extended by com.jidesoft.comparator.NumberComparator
All Implemented Interfaces:
Comparator<Object>

public class NumberComparator
extends Object
implements Comparator<Object>

Comparator for Number type. This is a singleton class. Call getInstance() to get the comparator.


Field Summary
static ComparatorContext CONTEXT_ABSOLUTE
          Comparator Context to compare two values using the absolute value.
 
Constructor Summary
protected NumberComparator()
          Constructor.
 
Method Summary
 int compare(Object o1, Object o2)
          Compares two Numbers.
static NumberComparator getInstance()
          Returns NumberComparator singleton.
 boolean isAbsolute()
          Checks if if the values are compared using the absolute values.
 void setAbsolute(boolean absolute)
          Sets the flag to compare the values using the absolute value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Field Detail

CONTEXT_ABSOLUTE

public static final ComparatorContext CONTEXT_ABSOLUTE
Comparator Context to compare two values using the absolute value.

Constructor Detail

NumberComparator

protected NumberComparator()
Constructor.

Has protected access to prevent other clients creating instances of the class ... it is stateless so we need only one instance.

Method Detail

getInstance

public static NumberComparator getInstance()
Returns NumberComparator singleton.

Returns:
an instance of NumberComparator.

compare

public int compare(Object o1,
                   Object o2)
Compares two Numbers.

Specified by:
compare in interface Comparator<Object>
Parameters:
o1 - the first object to be compared
o2 - the second object to be compared
Returns:
0 if a and b are equal, -1 if a is less than b, 1 if a is more than b.

isAbsolute

public boolean isAbsolute()
Checks if if the values are compared using the absolute values.

Returns:
true or false.

setAbsolute

public void setAbsolute(boolean absolute)
Sets the flag to compare the values using the absolute value.

Parameters:
absolute - true or false.

JIDE 3.5.15