quick.dbtable
Interface Comparator
- public interface Comparator
When you want to do a special comparison during sorting, this class can be used.
For example if you want do case insensitive sort, then during sorting, this compare method
will be called and you have to implement the logic for case insensitive comparison
in the compare method in this class
A sample class to handle norwegian characters.
class NorwegianComparator implements quick.dbtable.Comparator
{
String Norwegian = "< a,A< b,B< c,C< d,D< e,E< f,F< g,G< h,H< i,I< j,J" +
"< k,K< l,L< m,M< n,N< o,O< p,P< q,Q< r,R< s,S< t,T" +
"< u,U< v,V< w,W< x,X< y,Y< z,Z" +
"< å=a?,Å=A?" +
";aa,AA< æ,Æ< ø,Ø";
java.text.RuleBasedCollator myNorwegian;
public NorwegianComparator()
{
try{
myNorwegian = new java.text.RuleBasedCollator(Norwegian);
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
public int compare(int column, java.lang.Object currentData, java.lang.Object nextData)
{
//if column == column which has norwegian characters, then
return myNorwegian.compare(currentData, nextData);
//else
return quick.dbtable.Comparator.DEFAULT_SORT;
}
}
NorwegianComparator mc = new NorwegianComparator();
dbTable.setComparator(mc);
Method Summary |
int |
compare(int column,
java.lang.Object currentData,
java.lang.Object nextData)
compares cell data in a given column |
DEFAULT_SORT
public static final int DEFAULT_SORT
- See Also:
- Constant Field Values
compare
public int compare(int column,
java.lang.Object currentData,
java.lang.Object nextData)
- compares cell data in a given column
- Parameters:
column
- currentData
- nextData
-
- Returns:
DBTable.EQUAL if both objects are equal
DBTable.LESS if nextData is less than currentData
DBTable.GREATER if nextData is greater than currentData
DBTable.DEFAULT_SORT if you haven't done the comparison & if you wnat quicktable to do the comparison, return this.
This is mainly used, if you want to handle the comparison for some columns and
for all the other coolumn, you want quicktable to do its default comparison