001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.runtime.util; 020 021import java.util.Date; 022 023import lucee.runtime.exp.PageException; 024 025/** 026 * class to compare objects and primitive value types 027 */ 028public interface Operation { 029 030 /** 031 * compares two Objects 032 * @param left 033 * @param right 034 * @return different of objects as int 035 * @throws PageException 036 */ 037 public int compare(Object left, Object right) throws PageException; 038 039 /** 040 * compares a Object with a String 041 * @param left 042 * @param right 043 * @return difference as int 044 * @throws PageException 045 */ 046 public int compare(Object left, String right) throws PageException ; 047 048 /** 049 * compares a Object with a double 050 * @param left 051 * @param right 052 * @return difference as int 053 * @throws PageException 054 */ 055 public int compare(Object left, double right) throws PageException; 056 057 /** 058 * compares a Object with a boolean 059 * @param left 060 * @param right 061 * @return difference as int 062 * @throws PageException 063 */ 064 public int compare(Object left, boolean right) throws PageException; 065 066 /** 067 * compares a Object with a Date 068 * @param left 069 * @param right 070 * @return difference as int 071 * @throws PageException 072 */ 073 public int compare(Object left, Date right) throws PageException; 074 075 /** 076 * compares a String with a Object 077 * @param left 078 * @param right 079 * @return difference as int 080 * @throws PageException 081 */ 082 public int compare(String left, Object right) throws PageException; 083 084 /** 085 * compares a String with a String 086 * @param left 087 * @param right 088 * @return difference as int 089 */ 090 public int compare(String left, String right); 091 092 /** 093 * compares a String with a double 094 * @param left 095 * @param right 096 * @return difference as int 097 */ 098 public int compare(String left, double right); 099 100 /** 101 * compares a String with a boolean 102 * @param left 103 * @param right 104 * @return difference as int 105 */ 106 public int compare(String left, boolean right); 107 108 /** 109 * compares a String with a Date 110 * @param left 111 * @param right 112 * @return difference as int 113 * @throws PageException 114 */ 115 public int compare(String left, Date right) throws PageException; 116 117 /** 118 * compares a double with a Object 119 * @param left 120 * @param right 121 * @return difference as int 122 * @throws PageException 123 */ 124 public int compare(double left, Object right) throws PageException; 125 126 /** 127 * compares a double with a String 128 * @param left 129 * @param right 130 * @return difference as int 131 */ 132 public int compare(double left, String right); 133 134 /** 135 * compares a double with a double 136 * @param left 137 * @param right 138 * @return difference as int 139 */ 140 public int compare(double left, double right); 141 142 /** 143 * compares a double with a boolean 144 * @param left 145 * @param right 146 * @return difference as int 147 */ 148 public int compare(double left, boolean right); 149 150 /** 151 * compares a double with a Date 152 * @param left 153 * @param right 154 * @return difference as int 155 */ 156 public int compare(double left, Date right); 157 158 /** 159 * compares a boolean with a Object 160 * @param left 161 * @param right 162 * @return difference as int 163 * @throws PageException 164 */ 165 public int compare(boolean left, Object right) throws PageException; 166 167 /** 168 * compares a boolean with a double 169 * @param left 170 * @param right 171 * @return difference as int 172 */ 173 public int compare(boolean left, double right); 174 175 /** 176 * compares a boolean with a double 177 * @param left 178 * @param right 179 * @return difference as int 180 */ 181 public int compare(boolean left, String right); 182 183 /** 184 * compares a boolean with a boolean 185 * @param left 186 * @param right 187 * @return difference as int 188 */ 189 public int compare(boolean left, boolean right); 190 191 /** 192 * compares a boolean with a Date 193 * @param left 194 * @param right 195 * @return difference as int 196 */ 197 public int compare(boolean left, Date right); 198 199 /** 200 * compares a Date with a Object 201 * @param left 202 * @param right 203 * @return difference as int 204 * @throws PageException 205 */ 206 public int compare(Date left, Object right) throws PageException; 207 208 /** 209 * compares a Date with a String 210 * @param left 211 * @param right 212 * @return difference as int 213 * @throws PageException 214 */ 215 public int compare(Date left, String right) throws PageException; 216 217 /** 218 * compares a Date with a double 219 * @param left 220 * @param right 221 * @return difference as int 222 */ 223 public int compare(Date left, double right); 224 225 /** 226 * compares a Date with a boolean 227 * @param left 228 * @param right 229 * @return difference as int 230 */ 231 public int compare(Date left, boolean right); 232 233 /** 234 * compares a Date with a Date 235 * @param left 236 * @param right 237 * @return difference as int 238 */ 239 public int compare(Date left, Date right); 240 241 /** 242 * Method to compare to different values, return true of objects are same otherwise false 243 * @param left left value to compare 244 * @param right right value to compare 245 * @param caseSensitive check case sensitive or not 246 * @return is same or not 247 * @throws PageException 248 */ 249 public boolean equals(Object left, Object right, boolean caseSensitive) throws PageException; 250 251 /** 252 * check if left is inside right (String-> ignore case) 253 * @param left string to check 254 * @param right substring to find in string 255 * @return return if substring has been found 256 * @throws PageException 257 */ 258 public boolean ct(Object left, Object right) throws PageException; 259 260 /** 261 * Equivalence: Return True if both operands are True or both are False. The EQV operator is the opposite of the XOR operator. For example, True EQV True is True, but True EQV False is False. 262 * @param left value to check 263 * @param right value to check 264 * @return result of operation 265 * @throws PageException 266 */ 267 public boolean eqv(Object left, Object right) throws PageException; 268 269 /** 270 * Implication: The statement A IMP B is the equivalent of the logical statement 271 * "If A Then B." A IMP B is False only if A is True and B is False. It is True in all other cases. 272 * @param left value to check 273 * @param right value to check 274 * @return result 275 * @throws PageException 276 */ 277 public boolean imp(Object left, Object right) throws PageException; 278 279 /** 280 * check if left is not inside right (String-> ignore case) 281 * @param left string to check 282 * @param right substring to find in string 283 * @return return if substring NOT has been found 284 * @throws PageException 285 */ 286 public boolean nct(Object left, Object right) throws PageException; 287 288 /** 289 * calculate the exponent of the left value 290 * @param left value to get exponent from 291 * @param right exponent count 292 * @return return expoinended value 293 * @throws PageException 294 */ 295 public double exponent(Object left, Object right) throws PageException; 296 297 298 /** 299 * concat to Strings 300 * @param left 301 * @param right 302 * @return concated String 303 */ 304 public String concat(String left,String right); 305 306 /** 307 * plus operation 308 * @param left 309 * @param right 310 * @return result of the opertions 311 */ 312 public double plus(double left, double right); 313 314 /** 315 * minus operation 316 * @param left 317 * @param right 318 * @return result of the opertions 319 */ 320 public double minus(double left, double right); 321 322 /** 323 * modulus operation 324 * @param left 325 * @param right 326 * @return result of the opertions 327 */ 328 public double modulus(double left, double right); 329 330 /** 331 * divide operation 332 * @param left 333 * @param right 334 * @return result of the opertions 335 */ 336 public double divide(double left, double right); 337 338 /** 339 * multiply operation 340 * @param left 341 * @param right 342 * @return result of the opertions 343 */ 344 public double multiply(double left, double right); 345}