KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > calipso > reportgenerator > reportcalculator > expression > FloatComparator


1 package com.calipso.reportgenerator.reportcalculator.expression;
2
3 //import com.calipso.reportgenerator.reportcalculator.CubeFloat;
4
import com.calipso.reportgenerator.reportcalculator.SharedFloat;
5
6 import java.util.Comparator JavaDoc;
7
8 /**
9  * User: pgore
10  * Date: May 30, 2003
11  * Time: 11:55:27 AM
12  */

13 public class FloatComparator implements Comparator JavaDoc {
14   public int compare(Object JavaDoc o1, Object JavaDoc o2) {
15 /* if (o2 instanceof CubeFloat){
16       return ((Float)o1).compareTo(new Float(((CubeFloat)o2).floatValue()));
17     } */

18
19     if(o2 instanceof String JavaDoc) {
20       SharedFloat sharedFloat = SharedFloat.newFrom(Float.valueOf(o2.toString()));
21       return ((SharedFloat)o1).compareTo(sharedFloat);
22     } else {
23       return ((SharedFloat)o1).compareTo(o2);
24     }
25   }
26 }
27
Popular Tags