1 package com.teamkonzept.lib; 2 3 public class TKSortableInteger implements TKSortable { 4 5 private Integer value; 6 7 public TKSortableInteger (int value) { this.value = new Integer (value); } 8 public TKSortableInteger (String s) { this.value = new Integer (s); } 9 public String toString () { return value.toString(); } 10 public int intValue () { return value.intValue(); } 11 12 public int cmp (TKSortable other) { 13 14 if (other instanceof TKSortableInteger) { 15 16 int thisValue = value.intValue(); 17 int otherValue = ((TKSortableInteger) other).intValue(); 18 19 if (thisValue < otherValue) return -1; 20 else if (thisValue > otherValue) return 1; 21 else return 0; 22 23 } else return value.toString().compareTo (other.toString()); 24 }; 25 } 26 | Popular Tags |