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