FTP-Server API

graphic.services
Interface JQTableSortMethod


public interface JQTableSortMethod

This interface is to be implemented by the one who wants to make a sorting criteria for a JQTable. The classes one method is called every time two celles is compared to each other. If a comparisment is not possible, -2 should be returned, and comparisment will continue as normal.


Method Summary
 int compareTo(Object me, Object other)
          Compares the object itself(me) with another object(other).
 

Method Detail

compareTo

public int compareTo(Object me,
                     Object other)
Compares the object itself(me) with another object(other).
If the object that is compared with is larger than the object itself -1 should be returned. If they are equal, 0 should be returned, and if the compared object is less than the object itself, 1 should be returned. If the objects cannot be compared, -2 should be returned. After this, the object wil be compared after standard sorting methods (String and int)

a method to comparisment of numbers would look like this:

public int compareTo(Object me, Object other){
 try{
   int num1 = Integer.parseInt(me.toString());
   int num2 = Integer.parseInt(other.toString());

   if (num1 == num2)
     return 0;
   if (num1 < num2)
     return -1;
   else
     return 1;

 }catch(NumberFormatException nfe){
   return -2;
 }
}

Parameters:
me - The object it selv.
other - The object to compare with
Returns:
-2, -1, 0, 1

FTP-Server API