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.cfx; 020 021import java.io.IOException; 022 023import lucee.runtime.PageContext; 024import lucee.runtime.exp.PageException; 025 026import com.allaire.cfx.Query; 027import com.allaire.cfx.Response; 028 029 030 031/** 032 * 033 */ 034public final class ResponseImpl implements Response { 035 036 private PageContext pc; 037 private boolean debug; 038 039 040 /** 041 * @param pc 042 * @param debug 043 */ 044 public ResponseImpl(PageContext pc,boolean debug) { 045 this.pc=pc; 046 this.debug=debug; 047 } 048 049 @Override 050 public Query addQuery(String name, String[] column) { 051 lucee.runtime.type.Query query=new lucee.runtime.type.QueryImpl(column,0,name); 052 053 try { 054 pc.setVariable(name,query); 055 } 056 catch (PageException e) { 057 } 058 return new QueryWrap(query); 059 } 060 061 @Override 062 public void setVariable(String key, String value) { 063 try { 064 pc.setVariable(key,value); 065 } 066 catch (PageException e) { 067 } 068 } 069 070 @Override 071 public void write(String str) { 072 try { 073 pc.write(str); 074 } catch (IOException e) { 075 076 } 077 } 078 079 @Override 080 public void writeDebug(String str) { 081 if(debug)write(str); 082 } 083 084}