00001 package cedar.jetweb.util; 00002 00009 public class Match { 00010 00011 public static String GEN="Generator"; 00012 public static String VER="Version"; 00013 public static String PHPDF="Photon PDF"; 00014 public static String PRPDF="Proton PDF"; 00015 00016 private String name=""; 00017 private Object value1=null; 00018 private Object value2=null; 00019 00020 public Match(String name, Object val1, Object val2){ 00021 this.name=name; 00022 this.value1=val1; 00023 this.value2=val2; 00024 } 00025 00026 public String getName(){ 00027 return name; 00028 } 00029 public String getValue1(){ 00030 return value1.toString(); 00031 } 00032 public String getValue2(){ 00033 return value2.toString(); 00034 } 00035 00036 00040 public static boolean compareDouble(Double val1, Double val2){ 00041 00042 Double diff = val1 - val2; 00043 boolean equal = 00044 Math.abs(diff) <= (Math.abs(val1)+Math.abs(val2)) * 0.00005 || 00045 //0.00000005 || 00046 val1==val2; 00047 return equal; 00048 } 00049 00058 public static <T> boolean compare(T val1, T val2){ 00059 00060 if(val1 instanceof Integer){ 00061 return ((Integer)val1).equals((Integer)val2); 00062 } 00063 00064 if(val1 instanceof Double){ 00065 return compareDouble((Double)val1, (Double)val2); 00066 } 00067 00068 return false; 00069 } 00070 00071 } 00072 00073 00074 00075 00076 00077 00078 00079 00080
Generated Wed Jan 17 09:14:27 GMT 2007