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 com.allaire.cfx; 020 021import lucee.loader.engine.CFMLEngineFactory; 022import lucee.runtime.cfx.QueryWrap; 023 024/** 025 * Implementation of the DebugQuery 026 */ 027public final class DebugQuery extends QueryWrap { 028 029 /** 030 * Constructor of the DebugQuery 031 * @param name 032 * @param columns 033 * @param data 034 * @throws IllegalArgumentException 035 */ 036 public DebugQuery(String name, String[] columns, String[][] data) throws IllegalArgumentException { 037 super(toQuery(name, columns, data),name); 038 } 039 040 /** 041 * Constructor of the DebugQuery 042 * @param name 043 * @param columns 044 * @throws IllegalArgumentException 045 */ 046 public DebugQuery(String name, String[] columns) throws IllegalArgumentException { 047 super(toQuery(name, columns,0),name); 048 } 049 050 private static lucee.runtime.type.Query toQuery(String name, String[] columns, String[][] data) { 051 052 lucee.runtime.type.Query query=toQuery(name, columns,data.length); 053 054 for(int row=0;row<data.length;row++) { 055 int len=data[row].length>columns.length?columns.length:data[row].length; 056 for(int col=0;col<len;col++) { 057 try { 058 query.setAt(columns[col],row+1,data[row][col]); 059 } catch (Exception e) {} 060 } 061 } 062 return query; 063 } 064 private static lucee.runtime.type.Query toQuery(String name, String[] columns, int rows) { 065 return CFMLEngineFactory.getInstance().getCreationUtil().createQuery(columns,rows,name); 066 } 067}