de.dfg.oc.logfileanalyzer.gui
Class TableElementComparator

java.lang.Object
  extended by de.dfg.oc.logfileanalyzer.gui.TableElementComparator
All Implemented Interfaces:
Comparator<String>

 class TableElementComparator
extends Object
implements Comparator<String>

Compares the content of table cells to support sorting.

Author:
Clemens Gersbacher, Holger Prothmann

Constructor Summary
TableElementComparator()
           
 
Method Summary
 int compare(String s1, String s2)
          Compares two Strings provided as parameters.
 
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

TableElementComparator

TableElementComparator()
Method Detail

compare

public int compare(String s1,
                   String s2)
Compares two Strings provided as parameters. The method tries to convert the given Strings to double-values before comparison. If the conversion fails, the comparator compares the given Strings directly. Use this method only for Strings that can both(!) be either converted or not converted to doubles.

Specified by:
compare in interface Comparator<String>
Parameters:
s1 - first String to compare
s2 - second String to compare
Returns:
-1 if s1 < s1, 0 if s1 = s1, 1 otherwise