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