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.tag; 020 021import lucee.runtime.exp.PageException; 022import lucee.runtime.ext.tag.TagImpl; 023import lucee.runtime.functions.dynamicEvaluation.Evaluate; 024import lucee.runtime.op.Caster; 025 026/** 027* Outputs variables for debugging purposes. Using cfdump, you can display the contents of simple variables, queries, 028* arrays, structures, and WDDX variables created with cfwddx. if no var attribute defined it dump the hole site information 029* 030* 031* 032**/ 033public final class Dump extends TagImpl { 034 035 036 /** Variable to display. Enclose a variable name in pound signs */ 037 private Object var; 038 039 /** Name of Variable to display */ 040 private Object eval; 041 042 /** string; header for the dump output. */ 043 private String label; 044 private String format; 045 private String output; 046 //private double maxlevel=Integer.MAX_VALUE; 047 048 private boolean expand=true; 049 050 private int top=9999; 051 private String hide; 052 private String show; 053 054 private double keys=9999; 055 private boolean showUDFs=true; 056 057 private boolean metainfo=true; 058 private boolean abort=false; 059 060 061 @Override 062 public void release() { 063 super.release(); 064 var=null; 065 eval=null; 066 label=null; 067 //maxlevel=Integer.MAX_VALUE; 068 format=null; 069 output=null; 070 expand=true; 071 top=9999; 072 hide=null; 073 show=null; 074 keys=9999; 075 metainfo=true; 076 showUDFs=true; 077 abort=false; 078 } 079 080 081 082 /** 083 * @param top the top to set 084 */ 085 public void setTop(double top) { 086 this.top = (int) top+1; 087 } 088 public void setHide(String hide) { 089 this.hide = hide; 090 } 091 public void setShow(String show) { 092 this.show = show; 093 } 094 public void setOutput(String output) { 095 this.output = output; 096 } 097 public void setKeys(double keys) { 098 this.keys = keys; 099 } 100 public void setMetainfo(boolean metainfo) { 101 this.metainfo = metainfo; 102 } 103 104 105 106 /** set the value expand 107 * not supported at the moment 108 * @param expand value to set 109 **/ 110 public void setExpand(boolean expand) { 111 this.expand=expand; 112 } 113 114 /** set the value var 115 * Variable to display. Enclose a variable name in pound signs 116 * @param var value to set 117 **/ 118 public void setVar(Object var) { 119 this.var=var; 120 } 121 122 /** set the value eval 123 * Variable to display. Enclose a variable name in pound signs 124 * @param eval value to set 125 **/ 126 public void setEval(Object eval) { 127 this.eval=eval; 128 } 129 130 /** set the value label 131 * string; header for the dump output. 132 * @param label value to set 133 **/ 134 public void setLabel(String label) { 135 this.label=label; 136 } 137 138 /** 139 * @param maxlevel the maxlevel to set 140 */ 141 public void setMaxlevel(double maxlevel) { 142 this.top = (int) maxlevel; 143 } 144 145 /** 146 * @param type the type to set 147 */ 148 public void setType(String type) { 149 this.format = type; 150 } 151 public void setFormat(String format) { 152 this.format = format; 153 } 154 155 156 @Override 157 public int doStartTag() throws PageException { 158 if(var==null && eval!=null) { 159 var=Evaluate.call(pageContext,new Object[]{eval}); 160 if(label==null)label=Caster.toString(eval); 161 } 162 163 lucee.runtime.functions.other.Dump.call(pageContext,var,label,expand,top,show,hide,output,format,keys,metainfo,showUDFs); 164 if(abort)throw new lucee.runtime.exp.Abort(lucee.runtime.exp.Abort.SCOPE_REQUEST); 165 return SKIP_BODY; 166 } 167 168 @Override 169 public int doEndTag() { 170 return EVAL_PAGE; 171 } 172 173 174 175 /** 176 * @param showUDFs the showUDFs to set 177 */ 178 public void setShowudfs(boolean showUDFs) { 179 this.showUDFs = showUDFs; 180 } 181 182 183 184 /** 185 * @param abort the abort to set 186 */ 187 public void setAbort(boolean abort) { 188 this.abort = abort; 189 } 190 191}