private Vector addAnchorString(Vector list, String field, double diff) { Vector topIndex = new Vector(); Hashtable topIndexParms, currEntry; double lastValue, currValue; if (list.size() == 0) return null; currEntry = (Hashtable) list.get(0); lastValue = Common.parseDouble((String) currEntry.get(field)) + diff; for (int i = 1; i < list.size(); i++) { currEntry = (Hashtable) list.get(i); currValue = Common.parseDouble((String) currEntry.get(field)); if (currValue >= lastValue) { // Values for navigation line topIndexParms = new Hashtable(); topIndexParms.put("HREF", Convert.toString(i)); topIndexParms.put("TEXT", Convert.toString(lastValue)); topIndex.add(topIndexParms); // add anchor entry to list currEntry.put("ANCHORNAME", Convert.toString(i)); currEntry.put("ANCHORTEXT", Convert.toString(lastValue)); lastValue = currValue + diff; } else { // clear value from previous run currEntry.put("ANCHORNAME", ""); currEntry.put("ANCHORTEXT", ""); } list.set(i, currEntry); } return topIndex; }
public int compare(Object o1, Object o2) { Hashtable hash1 = (Hashtable) o1; Hashtable hash2 = (Hashtable) o2; String str1, str2; double dbl1, dbl2; str1 = hash1.get(compareWhat).toString().toLowerCase(); str2 = hash2.get(compareWhat).toString().toLowerCase(); if (this.compareWhat.equals("WAYPOINT")) { str1 = hash1.get(compareWhat).toString().substring(2).toLowerCase(); str2 = hash2.get(compareWhat).toString().substring(2).toLowerCase(); } if (this.compareWhat.equals("DISTANCE")) { dbl1 = Common.parseDouble(str1.substring(0, str1.length() - 3)); dbl2 = Common.parseDouble(str2.substring(0, str2.length() - 3)); if (dbl1 > dbl2) return 1; if (dbl1 < dbl2) return -1; else return 0; } else { return str1.compareTo(str2); } }