1 55 package org.lateralnz.common.wrapper; 56 57 import java.io.Serializable ; 58 59 import org.lateralnz.common.util.Constants; 60 61 64 public class IntHolder implements Serializable , Comparable , Constants { 65 66 public int value; 67 68 public IntHolder(int value) { 69 this.value = value; 70 } 71 72 public int compareTo(Object obj) { 73 if (obj == null) { 74 return -1; 75 } 76 77 int compval; 78 79 if (obj instanceof IntHolder) { 80 IntHolder ih = (IntHolder)obj; 81 compval = ih.value; 82 } 83 else if (obj instanceof String ) { 84 compval = Integer.parseInt((String )obj); 85 } 86 else { 87 return -1; 88 } 89 90 if (this.value == compval) { 91 return 0; 92 } 93 else if (this.value > compval) { 94 return 1; 95 } 96 else { 97 return -1; 98 } 99 } 100 101 public String toString() { 102 return Integer.toString(value); 103 } 104 } | Popular Tags |