01: package com.teamkonzept.lib;
02:
03: public class TKSortableInteger implements TKSortable {
04:
05: private Integer value;
06:
07: public TKSortableInteger(int value) {
08: this .value = new Integer(value);
09: }
10:
11: public TKSortableInteger(String s) {
12: this .value = new Integer(s);
13: }
14:
15: public String toString() {
16: return value.toString();
17: }
18:
19: public int intValue() {
20: return value.intValue();
21: }
22:
23: public int cmp(TKSortable other) {
24:
25: if (other instanceof TKSortableInteger) {
26:
27: int this Value = value.intValue();
28: int otherValue = ((TKSortableInteger) other).intValue();
29:
30: if (this Value < otherValue)
31: return -1;
32: else if (this Value > otherValue)
33: return 1;
34: else
35: return 0;
36:
37: } else
38: return value.toString().compareTo(other.toString());
39: };
40: }
|