1 21 22 27 28 package javax.mail.search; 29 30 36 public abstract class IntegerComparisonTerm extends ComparisonTerm { 37 42 protected int number; 43 44 private static final long serialVersionUID = -6963571240154302484L; 45 46 protected IntegerComparisonTerm(int comparison, int number) { 47 this.comparison = comparison; 48 this.number = number; 49 } 50 51 54 public int getNumber() { 55 return number; 56 } 57 58 61 public int getComparison() { 62 return comparison; 63 } 64 65 protected boolean match(int i) { 66 switch (comparison) { 67 case LE: 68 return i <= number; 69 case LT: 70 return i < number; 71 case EQ: 72 return i == number; 73 case NE: 74 return i != number; 75 case GT: 76 return i > number; 77 case GE: 78 return i >= number; 79 default: 80 return false; 81 } 82 } 83 84 87 public boolean equals(Object obj) { 88 if (!(obj instanceof IntegerComparisonTerm )) 89 return false; 90 IntegerComparisonTerm ict = (IntegerComparisonTerm )obj; 91 return ict.number == this.number && super.equals(obj); 92 } 93 94 97 public int hashCode() { 98 return number + super.hashCode(); 99 } 100 } 101 | Popular Tags |