001 package railo.runtime.query; 002 003 import java.util.Iterator; 004 005 import railo.runtime.PageContext; 006 import railo.runtime.dump.DumpData; 007 import railo.runtime.dump.DumpProperties; 008 import railo.runtime.exp.DatabaseException; 009 import railo.runtime.exp.PageException; 010 import railo.runtime.exp.PageRuntimeException; 011 import railo.runtime.type.Collection; 012 import railo.runtime.type.QueryColumn; 013 import railo.runtime.type.Sizeable; 014 import railo.runtime.type.dt.DateTime; 015 import railo.runtime.type.util.QueryUtil; 016 017 public class QueryCacheQueryColumn implements QueryColumn,Sizeable { 018 019 private QueryCacheQuery qcq; 020 private QueryColumn column; 021 private Collection.Key key; 022 023 024 /** 025 * return a queryCacheQuery 026 * @param qcq 027 * @param key 028 * @return 029 * @throws DatabaseException 030 */ 031 public static QueryColumn getColumn(QueryCacheQuery qcq, Key key) throws DatabaseException { 032 QueryColumn _column = qcq.getQuery().getColumn(key); 033 return new QueryCacheQueryColumn(qcq,_column,key); 034 } 035 036 /** 037 * return a queryCacheQuery 038 * @param qcq 039 * @param key 040 * @param defaultValue 041 * @return 042 */ 043 public static QueryColumn getColumn(QueryCacheQuery qcq, Key key, QueryColumn defaultValue) { 044 QueryColumn _column = qcq.getQuery().getColumn(key,null); 045 if(_column==null) return defaultValue; 046 return new QueryCacheQueryColumn(qcq,_column,key); 047 } 048 049 /** 050 * Constructor of the class 051 * @param qcq 052 * @param column 053 * @param key 054 */ 055 private QueryCacheQueryColumn(QueryCacheQuery qcq, QueryColumn column, Key key) { 056 this.qcq=qcq; 057 this.column=column; 058 this.key=key; 059 } 060 061 private void disconnectCache() { 062 qcq.disconnectCache(); 063 try { 064 column=qcq.getQuery().getColumn(key); 065 } catch (DatabaseException e) { 066 throw new PageRuntimeException(e); 067 } 068 } 069 070 /** 071 * 072 * @see railo.runtime.type.QueryColumn#add(java.lang.Object) 073 */ 074 public void add(Object value) { 075 disconnectCache(); 076 column.add(value); 077 } 078 079 /** 080 * 081 * @see railo.runtime.type.QueryColumn#addRow(int) 082 */ 083 public void addRow(int count) { 084 disconnectCache(); 085 column.addRow(count); 086 } 087 088 /** 089 * 090 * @see railo.runtime.type.QueryColumn#cutRowsTo(int) 091 */ 092 public void cutRowsTo(int maxrows) { 093 disconnectCache(); 094 column.cutRowsTo(maxrows); 095 } 096 097 /** 098 * 099 * @see railo.runtime.type.QueryColumn#get(int) 100 */ 101 public Object get(int row) throws PageException { 102 return column.get(row); 103 } 104 105 /** 106 * 107 * @see railo.runtime.type.QueryColumn#get(int, java.lang.Object) 108 */ 109 public Object get(int row, Object defaultValue) { 110 return column.get(row, defaultValue); 111 } 112 113 /** 114 * 115 * @see railo.runtime.type.QueryColumn#getType() 116 */ 117 public int getType() { 118 return column.getType(); 119 } 120 121 /** 122 * 123 * @see railo.runtime.type.QueryColumn#getTypeAsString() 124 */ 125 public String getTypeAsString() { 126 return column.getTypeAsString(); 127 } 128 129 /** 130 * 131 * @see railo.runtime.type.QueryColumn#remove(int) 132 */ 133 public Object remove(int row) throws PageException { 134 disconnectCache(); 135 return column.remove(row); 136 } 137 138 /** 139 * 140 * @see railo.runtime.type.QueryColumn#removeEL(int) 141 */ 142 public Object removeEL(int row) { 143 disconnectCache(); 144 return column.removeEL(row); 145 } 146 147 /** 148 * 149 * @see railo.runtime.type.QueryColumn#removeRow(int) 150 */ 151 public Object removeRow(int row) throws PageException { 152 disconnectCache(); 153 return column.removeRow(row); 154 } 155 156 /** 157 * 158 * @see railo.runtime.type.QueryColumn#set(int, java.lang.Object) 159 */ 160 public Object set(int row, Object value) throws PageException { 161 disconnectCache(); 162 return column.set(row, value); 163 } 164 165 /** 166 * 167 * @see railo.runtime.type.QueryColumn#setEL(int, java.lang.Object) 168 */ 169 public Object setEL(int row, Object value) { 170 disconnectCache(); 171 return column.setEL(row, value); 172 } 173 174 /** 175 * 176 * @see railo.runtime.type.Collection#clear() 177 */ 178 public void clear() { 179 disconnectCache(); 180 column.clear(); 181 } 182 183 /** 184 * 185 * @see railo.runtime.type.Collection#containsKey(java.lang.String) 186 */ 187 public boolean containsKey(String key) { 188 return column.containsKey(key); 189 } 190 191 /** 192 * 193 * @see railo.runtime.type.Collection#containsKey(railo.runtime.type.Collection.Key) 194 */ 195 public boolean containsKey(Key key) { 196 return column.containsKey(key); 197 } 198 199 /** 200 * 201 * @see railo.runtime.type.Collection#duplicate(boolean) 202 */ 203 public Collection duplicate(boolean deepCopy) { 204 return column.duplicate(deepCopy); 205 } 206 207 208 /** 209 * 210 * @see railo.runtime.type.Collection#get(java.lang.String) 211 */ 212 public Object get(String key) throws PageException { 213 return column.get(key); 214 } 215 216 /** 217 * 218 * @see railo.runtime.type.Collection#get(railo.runtime.type.Collection.Key) 219 */ 220 public Object get(Key key) throws PageException { 221 return column.get(key); 222 } 223 224 /** 225 * 226 * @see railo.runtime.type.Collection#get(java.lang.String, java.lang.Object) 227 */ 228 public Object get(String key, Object defaultValue) { 229 return column.get(key, defaultValue); 230 } 231 232 /** 233 * 234 * @see railo.runtime.type.Collection#get(railo.runtime.type.Collection.Key, java.lang.Object) 235 */ 236 public Object get(Key key, Object defaultValue) { 237 return column.get(key, defaultValue); 238 } 239 240 /** 241 * 242 * @see railo.runtime.type.Collection#keys() 243 */ 244 public Key[] keys() { 245 return column.keys(); 246 } 247 248 /** 249 * 250 * @see railo.runtime.type.Collection#keysAsString() 251 */ 252 public String[] keysAsString() { 253 return column.keysAsString(); 254 } 255 256 /** 257 * 258 * @see railo.runtime.type.Collection#remove(railo.runtime.type.Collection.Key) 259 */ 260 public Object remove(Key key) throws PageException { 261 disconnectCache(); 262 return column.remove(key); 263 } 264 265 266 /** 267 * 268 * @see railo.runtime.type.Collection#removeEL(railo.runtime.type.Collection.Key) 269 */ 270 public Object removeEL(Key key) { 271 disconnectCache(); 272 return column.removeEL(key); 273 } 274 275 /** 276 * 277 * @see railo.runtime.type.Collection#set(java.lang.String, java.lang.Object) 278 */ 279 public Object set(String key, Object value) throws PageException { 280 disconnectCache(); 281 return column.set(key, value); 282 } 283 284 /** 285 * 286 * @see railo.runtime.type.Collection#set(railo.runtime.type.Collection.Key, java.lang.Object) 287 */ 288 public Object set(Key key, Object value) throws PageException { 289 disconnectCache(); 290 return column.set(key, value); 291 } 292 293 /** 294 * 295 * @see railo.runtime.type.Collection#setEL(java.lang.String, java.lang.Object) 296 */ 297 public Object setEL(String key, Object value) { 298 disconnectCache(); 299 return column.setEL(key, value); 300 } 301 302 /** 303 * 304 * @see railo.runtime.type.Collection#setEL(railo.runtime.type.Collection.Key, java.lang.Object) 305 */ 306 public Object setEL(Key key, Object value) { 307 disconnectCache(); 308 return column.setEL(key, value); 309 } 310 311 /** 312 * 313 * @see railo.runtime.type.Collection#size() 314 */ 315 public int size() { 316 return column.size(); 317 } 318 319 /** 320 * 321 * @see railo.runtime.dump.Dumpable#toDumpData(railo.runtime.PageContext, int) 322 */ 323 public DumpData toDumpData(PageContext pageContext, int maxlevel, DumpProperties dp) { 324 return column.toDumpData(pageContext, maxlevel,dp); 325 } 326 327 /** 328 * 329 * @see railo.runtime.type.Iteratorable#iterator() 330 */ 331 public Iterator iterator() { 332 return column.iterator(); 333 } 334 335 /** 336 * 337 * @see railo.runtime.type.Iteratorable#keyIterator() 338 */ 339 public Iterator keyIterator() { 340 return column.keyIterator(); 341 } 342 343 /** 344 * 345 * @see railo.runtime.op.Castable#castToBooleanValue() 346 */ 347 public boolean castToBooleanValue() throws PageException { 348 return column.castToBooleanValue(); 349 } 350 351 /** 352 * @see railo.runtime.op.Castable#castToBoolean(java.lang.Boolean) 353 */ 354 public Boolean castToBoolean(Boolean defaultValue) { 355 return column.castToBoolean(defaultValue); 356 } 357 358 /** 359 * 360 * @see railo.runtime.op.Castable#castToDateTime() 361 */ 362 public DateTime castToDateTime() throws PageException { 363 return column.castToDateTime(); 364 } 365 366 /** 367 * @see railo.runtime.op.Castable#castToDateTime(railo.runtime.type.dt.DateTime) 368 */ 369 public DateTime castToDateTime(DateTime defaultValue) { 370 return column.castToDateTime(defaultValue); 371 } 372 373 /** 374 * 375 * @see railo.runtime.op.Castable#castToDoubleValue() 376 */ 377 public double castToDoubleValue() throws PageException { 378 return column.castToDoubleValue(); 379 } 380 381 /** 382 * @see railo.runtime.op.Castable#castToDoubleValue(double) 383 */ 384 public double castToDoubleValue(double defaultValue) { 385 return column.castToDoubleValue(defaultValue); 386 } 387 388 /** 389 * 390 * @see railo.runtime.op.Castable#castToString() 391 */ 392 public String castToString() throws PageException { 393 return column.castToString(); 394 } 395 396 /** 397 * @see railo.runtime.op.Castable#castToString(java.lang.String) 398 */ 399 public String castToString(String defaultValue) { 400 return column.castToString(defaultValue); 401 } 402 403 /** 404 * 405 * @see railo.runtime.op.Castable#compareTo(java.lang.String) 406 */ 407 public int compareTo(String str) throws PageException { 408 return column.compareTo(str); 409 } 410 411 /** 412 * 413 * @see railo.runtime.op.Castable#compareTo(boolean) 414 */ 415 public int compareTo(boolean b) throws PageException { 416 return column.compareTo(b); 417 } 418 419 /** 420 * 421 * @see railo.runtime.op.Castable#compareTo(double) 422 */ 423 public int compareTo(double d) throws PageException { 424 return column.compareTo(d); 425 } 426 427 /** 428 * 429 * @see railo.runtime.op.Castable#compareTo(railo.runtime.type.dt.DateTime) 430 */ 431 public int compareTo(DateTime dt) throws PageException { 432 return column.compareTo(dt); 433 } 434 435 /** 436 * 437 * @see railo.runtime.type.ref.Reference#get(railo.runtime.PageContext) 438 */ 439 public Object get(PageContext pc) throws PageException { 440 return column.get(pc); 441 } 442 443 /** 444 * 445 * @see railo.runtime.type.ref.Reference#get(railo.runtime.PageContext, java.lang.Object) 446 */ 447 public Object get(PageContext pc, Object defaultValue) { 448 return column.get(pc, defaultValue); 449 } 450 451 /** 452 * 453 * @see railo.runtime.type.ref.Reference#getKey() 454 */ 455 public Key getKey() throws PageException { 456 return column.getKey(); 457 } 458 459 /** 460 * 461 * @see railo.runtime.type.ref.Reference#getKeyAsString() 462 */ 463 public String getKeyAsString() throws PageException { 464 return column.getKeyAsString(); 465 } 466 467 /** 468 * 469 * @see railo.runtime.type.ref.Reference#getParent() 470 */ 471 public Object getParent() { 472 return qcq; 473 } 474 475 /** 476 * 477 * @see railo.runtime.type.ref.Reference#remove(railo.runtime.PageContext) 478 */ 479 public Object remove(PageContext pc) throws PageException { 480 disconnectCache(); 481 return column.remove(pc); 482 } 483 484 /** 485 * 486 * @see railo.runtime.type.ref.Reference#removeEL(railo.runtime.PageContext) 487 */ 488 public Object removeEL(PageContext pc) { 489 disconnectCache(); 490 return column.removeEL(pc); 491 } 492 493 /** 494 * 495 * @see railo.runtime.type.ref.Reference#set(railo.runtime.PageContext, java.lang.Object) 496 */ 497 public Object set(PageContext pc, Object value) throws PageException { 498 disconnectCache(); 499 return column.set(pc, value); 500 } 501 502 /** 503 * 504 * @see railo.runtime.type.ref.Reference#setEL(railo.runtime.PageContext, java.lang.Object) 505 */ 506 public Object setEL(PageContext pc, Object value) { 507 disconnectCache(); 508 return column.setEL(pc, value); 509 } 510 511 /** 512 * 513 * @see railo.runtime.type.ref.Reference#touch(railo.runtime.PageContext) 514 */ 515 public Object touch(PageContext pc) throws PageException { 516 disconnectCache(); 517 return column.touch(pc); 518 } 519 520 /** 521 * @see railo.runtime.type.ref.Reference#touchEL(railo.runtime.PageContext) 522 */ 523 public Object touchEL(PageContext pc) { 524 disconnectCache(); 525 return column.touchEL(pc); 526 } 527 528 /** 529 * 530 * @see java.lang.Object#clone() 531 */ 532 public Object clone() { 533 return column.clone(); 534 } 535 536 /** 537 * @see railo.runtime.type.Iteratorable#valueIterator() 538 */ 539 public Iterator valueIterator() { 540 return column.valueIterator(); 541 } 542 543 544 545 /** 546 * @see railo.runtime.type.Sizeable#sizeOf() 547 */ 548 public long sizeOf() { 549 return QueryUtil.sizeOf(column); 550 } 551 }