|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jamonapi.utils.JAMonArrayComparator
public class JAMonArrayComparator
This class allows you to compare Object[] arrays by multiple columns. It can also compare any Object that implements the ToArray interface. Each column will use the underlying Compareable interface in natural or reverse order depending on how it is added, or will use the passed in Comparator.
Note I took this code from fdsapi.com, and would like to eventually merge these 2 projects, so this class will eventually be replaced by the one in FDS.
Constructor Summary | |
---|---|
JAMonArrayComparator()
|
|
JAMonArrayComparator(int sortCol,
boolean naturalOrder)
Sort/compare the passed in col number starting at 0 in natural (true) or reverse (false) order based on the columns Compareable interface being called. |
Method Summary | |
---|---|
void |
addCompareCol(int sortCol)
Compare the passed in col in natural order |
void |
addCompareCol(int sortCol,
boolean naturalOrder)
Compare the passed in col in natural or reverse order |
void |
addCompareCol(int sortCol,
java.util.Comparator comparator)
Compare the passed in col based on the passed in Comparator |
int |
compare(java.lang.Object o1,
java.lang.Object o2)
Method used by the comparator interface. |
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 |
Constructor Detail |
---|
public JAMonArrayComparator()
public JAMonArrayComparator(int sortCol, boolean naturalOrder)
sortCol
- naturalOrder
- Method Detail |
---|
public void addCompareCol(int sortCol)
public void addCompareCol(int sortCol, boolean naturalOrder)
public void addCompareCol(int sortCol, java.util.Comparator comparator)
public int compare(java.lang.Object o1, java.lang.Object o2)
o1 < o2 - returns a negative integer o1 == o2 - returns zero o1 > o2 - returns a postitive integer
Iterate through all columns that should be compared (in the proper order) and call the Comparator for each of the column elements.
compare
in interface java.util.Comparator
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |