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