1 23 24 27 28 package org.objectweb.medor.expression.lib; 29 30 import org.objectweb.medor.expression.api.Expression; 31 import org.objectweb.medor.expression.api.Operator; 32 33 import java.sql.Time ; 34 import java.sql.Timestamp ; 35 import java.text.Collator ; 36 import java.util.Date ; 37 38 43 public class GreaterEqual extends BasicComparator { 44 45 private int strength = Collator.PRIMARY; 46 47 public GreaterEqual() { 48 } 49 50 public GreaterEqual(int strength) { 51 this.strength = strength; 52 } 53 54 public GreaterEqual(Expression l, Expression r) { 55 super(l, r); 56 } 57 public Object clone(Object clone, java.util.Map obj2clone) throws CloneNotSupportedException { 58 clone = super.clone(clone, obj2clone); 59 ((GreaterEqual) clone).strength = strength; 60 return clone; 61 } 62 63 public boolean evaluate(Object op1, Object op2) { 64 boolean result = false; 65 if (op1 instanceof Character ) { 66 Character o1 = (Character ) op1; 67 Character o2 = (Character ) op2; 68 result = (o1.compareTo(o2) >= 0); 69 } 70 else if (op1 instanceof Long ) { 71 Long o1 = (Long ) op1; 72 Long o2 = (Long ) op2; 73 result = (o1.compareTo(o2) >= 0); 74 } 75 else if (op1 instanceof Short ) { 76 Short o1 = (Short ) op1; 77 Short o2 = (Short ) op2; 78 result = (o1.compareTo(o2) >= 0); 79 } 80 else if (op1 instanceof Integer ) { 81 Integer o1 = (Integer ) op1; 82 Integer o2 = (Integer ) op2; 83 result = (o1.compareTo(o2) >= 0); 84 } 85 else if (op1 instanceof Float ) { 86 Float o1 = (Float ) op1; 87 Float o2 = (Float ) op2; 88 result = (o1.compareTo(o2) >= 0); 89 } 90 else if (op1 instanceof Double ) { 91 Double o1 = (Double ) op1; 92 Double o2 = (Double ) op2; 93 result = (o1.compareTo(o2) >= 0); 94 } 95 else if (op1 instanceof Byte ) { 96 Byte o1 = (Byte ) op1; 97 Byte o2 = (Byte ) op2; 98 result = (o1.compareTo(o2) >= 0); 99 } 100 else if (op1 instanceof Date ) { 101 Date o1 = (Date ) op1; 102 Date o2 = (Date ) op2; 103 result = (o1.compareTo(o2) >= 0); 104 105 } 106 else if (op1 instanceof Time ) { 107 Time o1 = (Time ) op1; 108 Time o2 = (Time ) op2; 109 result = (o1.compareTo(o2) >= 0); 110 111 } 112 else if (op1 instanceof Timestamp ) { 113 Timestamp o1 = (Timestamp ) op1; 114 Timestamp o2 = (Timestamp ) op2; 115 result = (o1.compareTo(o2) >= 0); 116 117 } 118 else if (op1 instanceof String ) { 119 Collator myCollator = Collator.getInstance(); 120 myCollator.setStrength(strength); 121 String o1 = (String ) op1; 122 String o2 = (String ) op2; 123 result = (myCollator.compare(o1, o2) >= 0); 124 } 125 return result; 126 } 127 128 public boolean evaluate(int op1, int op2) { 129 return (op1 >= op2); 130 } 131 132 public boolean evaluate(int op1, short op2) { 133 return (op1 >= op2); 134 } 135 136 public boolean evaluate(int op1, long op2) { 137 return (op1 >= op2); 138 } 139 140 public boolean evaluate(int op1, float op2) { 141 return (op1 >= op2); 142 } 143 144 public boolean evaluate(int op1, double op2) { 145 return (op1 >= op2); 146 } 147 148 public boolean evaluate(float op1, float op2) { 149 return (op1 >= op2); 150 } 151 152 public boolean evaluate(float op1, short op2) { 153 return (op1 >= op2); 154 } 155 156 public boolean evaluate(float op1, int op2) { 157 return (op1 >= op2); 158 } 159 160 public boolean evaluate(float op1, long op2) { 161 return (op1 >= op2); 162 } 163 164 public boolean evaluate(float op1, double op2) { 165 return (op1 >= op2); 166 } 167 168 public boolean evaluate(char op1, char op2) { 169 return (op1 >= op2); 170 } 171 172 public boolean evaluate(long op1, short op2) { 173 return (op1 >= op2); 174 } 175 176 public boolean evaluate(long op1, int op2) { 177 return (op1 >= op2); 178 } 179 180 public boolean evaluate(long op1, long op2) { 181 return (op1 >= op2); 182 } 183 184 public boolean evaluate(long op1, float op2) { 185 return (op1 >= op2); 186 } 187 188 public boolean evaluate(long op1, double op2) { 189 return (op1 >= op2); 190 } 191 192 public boolean evaluate(double op1, short op2) { 193 return (op1 >= op2); 194 } 195 196 public boolean evaluate(double op1, int op2) { 197 return (op1 >= op2); 198 } 199 200 public boolean evaluate(double op1, long op2) { 201 return (op1 >= op2); 202 } 203 204 public boolean evaluate(double op1, float op2) { 205 return (op1 >= op2); 206 } 207 208 public boolean evaluate(double op1, double op2) { 209 return (op1 >= op2); 210 } 211 212 public boolean evaluate(boolean op1, boolean op2) { 213 return false; 214 } 215 216 public boolean evaluate(String op1, String op2) { 217 Collator myCollator = Collator.getInstance(); 219 myCollator.setStrength(strength); 220 return (myCollator.compare(op1, op2) >= 0); 221 } 222 223 public String getOperatorString() { 224 return Operator.GREATEREQUAL; 225 } 226 227 } 228 229 | Popular Tags |