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 Lower extends BasicComparator { 40 41 private int strength = Collator.PRIMARY; 42 43 public Lower() { 44 } 45 46 public Lower(int strength) { 47 this.strength = strength; 48 } 49 50 public Lower(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 ((Lower) 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 } 67 else if (op1 instanceof Long ) { 68 Long o1 = (Long ) op1; 69 Long o2 = (Long ) op2; 70 result = (o1.compareTo(o2) < 0); 71 } 72 else if (op1 instanceof Short ) { 73 Short o1 = (Short ) op1; 74 Short o2 = (Short ) op2; 75 result = (o1.compareTo(o2) < 0); 76 } 77 else if (op1 instanceof Integer ) { 78 Integer o1 = (Integer ) op1; 79 Integer o2 = (Integer ) op2; 80 result = (o1.compareTo(o2) < 0); 81 } 82 else if (op1 instanceof Float ) { 83 Float o1 = (Float ) op1; 84 Float o2 = (Float ) op2; 85 result = (o1.compareTo(o2) < 0); 86 } 87 else if (op1 instanceof Double ) { 88 Double o1 = (Double ) op1; 89 Double o2 = (Double ) op2; 90 result = (o1.compareTo(o2) < 0); 91 } 92 else if (op1 instanceof Byte ) { 93 Byte o1 = (Byte ) op1; 94 Byte o2 = (Byte ) op2; 95 result = (o1.compareTo(o2) < 0); 96 } 97 else if (op1 instanceof Date ) { 98 Date o1 = (Date ) op1; 99 Date o2 = (Date ) op2; 100 result = (o1.compareTo(o2) < 0); 101 102 } 103 else if (op1 instanceof Time ) { 104 Time o1 = (Time ) op1; 105 Time o2 = (Time ) op2; 106 result = (o1.compareTo(o2) < 0); 107 108 } 109 else if (op1 instanceof Timestamp ) { 110 Timestamp o1 = (Timestamp ) op1; 111 Timestamp o2 = (Timestamp ) op2; 112 result = (o1.compareTo(o2) < 0); 113 114 } 115 else if (op1 instanceof String ) { 116 Collator myCollator = Collator.getInstance(); 117 myCollator.setStrength(strength); 118 String o1 = (String ) op1; 119 String o2 = (String ) op2; 120 result = (myCollator.compare(o1, o2) < 0); 121 } 122 return result; 123 } 124 125 public boolean evaluate(int op1, int op2) { 126 return (op1 < op2); 127 } 128 129 public boolean evaluate(int op1, short op2) { 130 return (op1 < op2); 131 } 132 133 public boolean evaluate(int op1, long op2) { 134 return (op1 < op2); 135 } 136 137 public boolean evaluate(int op1, float op2) { 138 return (op1 < op2); 139 } 140 141 public boolean evaluate(int op1, double op2) { 142 return (op1 < op2); 143 } 144 145 public boolean evaluate(float op1, float op2) { 146 return (op1 < op2); 147 } 148 149 public boolean evaluate(float op1, short op2) { 150 return (op1 < op2); 151 } 152 153 public boolean evaluate(float op1, int op2) { 154 return (op1 < op2); 155 } 156 157 public boolean evaluate(float op1, long op2) { 158 return (op1 < op2); 159 } 160 161 public boolean evaluate(float op1, double op2) { 162 return (op1 < op2); 163 } 164 165 public boolean evaluate(char op1, char op2) { 166 return (op1 < op2); 167 } 168 169 public boolean evaluate(long op1, short op2) { 170 return (op1 < op2); 171 } 172 173 public boolean evaluate(long op1, int op2) { 174 return (op1 < op2); 175 } 176 177 public boolean evaluate(long op1, long op2) { 178 return (op1 < op2); 179 } 180 181 public boolean evaluate(long op1, float op2) { 182 return (op1 < op2); 183 } 184 185 public boolean evaluate(long op1, double op2) { 186 return (op1 < op2); 187 } 188 189 public boolean evaluate(double op1, short op2) { 190 return (op1 < op2); 191 } 192 193 public boolean evaluate(double op1, int op2) { 194 return (op1 < op2); 195 } 196 197 public boolean evaluate(double op1, long op2) { 198 return (op1 < op2); 199 } 200 201 public boolean evaluate(double op1, float op2) { 202 return (op1 < op2); 203 } 204 205 public boolean evaluate(double op1, double op2) { 206 return (op1 < op2); 207 } 208 209 public boolean evaluate(boolean op1, boolean op2) { 210 return false; 211 } 212 213 public boolean evaluate(String op1, String op2) { 214 Collator myCollator = Collator.getInstance(); 215 myCollator.setStrength(strength); 216 return (myCollator.compare(op1, op2) < 0); 217 } 218 219 public String getOperatorString() { 220 return Operator.LOWER; 221 } 222 } 223 | Popular Tags |