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.dump;
020
021import java.util.ArrayList;
022import java.util.List;
023
024
025/**
026 * class to generate Lucee HTML Boxes for dumps
027 */
028public class DumpTable implements DumpData {
029
030        private List rows=new ArrayList();
031        private String title;
032        private String comment;
033        private String highLightColor;
034        private String normalColor;
035        private String borderColor;
036        private String fontColor;
037        private String width;
038        private String height;
039        private String type;
040        private String id;
041        private String ref;
042
043        public DumpTable(String highLightColor, String normalColor,String borderColor) {
044                this(null,highLightColor,normalColor,borderColor,borderColor);
045        }
046        public DumpTable(String type,String highLightColor, String normalColor,String borderColor) {
047                this(type,highLightColor,normalColor,borderColor,borderColor);
048        }
049        
050        public DumpTable(String type,String highLightColor, String normalColor,String borderColor, String fontColor) {
051                this.highLightColor=highLightColor;
052                this.normalColor=normalColor;
053                this.borderColor=borderColor;
054                this.fontColor=fontColor;
055                this.type=type;
056        }
057        
058        
059        
060        
061        /**
062         * @return returns if the box has content or not
063         */
064        public boolean isEmpty() {
065                return rows.isEmpty();
066        }
067
068        /**
069         * clear all data set in the HTMLBox
070         */
071        public void clear() {
072                rows.clear();
073        }
074
075    /**
076     * @param title sets the title of the HTML Box
077     */
078    public void setTitle(String title) {
079        this.title=title;
080    }
081    
082    /**
083     * returns the title of the DumpTable, if not defined returns null
084     * @return title of the DumpTable
085     */
086    public String getTitle() {
087        return title;
088    }
089
090    /**
091     * @param comment sets the comment of the HTML Box
092     */
093    public void setComment(String comment) {
094        this.comment=comment;
095    }
096    
097    /**
098     * returns the comment of the DumpTable, if not defined returns null
099     * @return title of the DumpTable
100     */
101    public String getComment() {
102        return comment;
103    }
104        
105        /**
106         * @param width sets the With of the HTML Box, can be a number or a procentual value
107         */
108        public void setWidth(String width) {
109                this.width=width;
110        }
111
112        /**
113         * @param height sets the Height of the HTML Box, can be a number or a procentual value
114         */
115        public void setHeight(String height) {
116                this.height=height;
117        }
118
119
120        /**
121         * @return the borderColor
122         */
123        public String getBorderColor() {
124                return borderColor;
125        }
126
127        /**
128         * @param borderColor the borderColor to set
129         */
130        public void setBorderColor(String borderColor) {
131                this.borderColor = borderColor;
132        }
133
134        /**
135         * @return the fontColor
136         */
137        public String getFontColor() {
138                return fontColor;
139        }
140
141        /**
142         * @param fontColor the fontColor to set
143         */
144        public void setFontColor(String fontColor) {
145                this.fontColor = fontColor;
146        }
147
148        /**
149         * @return the highLightColor
150         */
151        public String getHighLightColor() {
152                return highLightColor;
153        }
154
155        /**
156         * @param highLightColor the highLightColor to set
157         */
158        public void setHighLightColor(String highLightColor) {
159                this.highLightColor = highLightColor;
160        }
161
162        /**
163         * @return the normalColor
164         */
165        public String getNormalColor() {
166                return normalColor;
167        }
168
169        /**
170         * @param normalColor the normalColor to set
171         */
172        public void setNormalColor(String normalColor) {
173                this.normalColor = normalColor;
174        }
175
176        /**
177         * @return the height
178         */
179        public String getHeight() {
180                return height;
181        }
182
183        /**
184         * @return the rows
185         */
186        public DumpRow[] getRows() {
187                return (DumpRow[])rows.toArray(new DumpRow[rows.size()]);
188        }
189
190        public void appendRow(DumpRow row) {
191                rows.add(row);
192        }
193        
194        public void appendRow(int highlightType, DumpData item1) {
195                appendRow(new DumpRow(highlightType,new DumpData[]{item1}));
196        }
197
198    public void appendRow(int highlightType, DumpData item1, DumpData item2) {
199        appendRow(new DumpRow(highlightType,new DumpData[]{item1,item2}));
200        }
201
202        public void appendRow(int highlightType, DumpData item1, DumpData item2, DumpData item3) {
203                appendRow(new DumpRow(highlightType,new DumpData[]{item1,item2,item3}));
204        }
205        
206        public void appendRow(int highlightType, DumpData item1, DumpData item2, DumpData item3,DumpData item4) {
207                appendRow(new DumpRow(highlightType,new DumpData[]{item1,item2,item3,item4}));
208        }
209        
210        public void appendRow(int highlightType, DumpData item1, DumpData item2, DumpData item3,DumpData item4, DumpData item5) {
211                appendRow(new DumpRow(highlightType,new DumpData[]{item1,item2,item3,item4,item5}));
212        }
213
214        public void appendRow(int highlightType, DumpData item1, DumpData item2, DumpData item3,DumpData item4, DumpData item5, DumpData item6) {
215                appendRow(new DumpRow(highlightType,new DumpData[]{item1,item2,item3,item4,item5,item6}));
216        }
217        
218
219        public void prependRow(DumpRow row) {
220                rows.add(0, row);
221        }
222
223        /**
224         * @return the width
225         */
226        public String getWidth() {
227                return width;
228        }
229
230        /**
231         * @return the type
232         */
233        public String getType() {
234                return type;
235        }
236
237        public void setId(String id) {
238                this.id=id;
239        }
240
241        public String getId() {
242                return id;
243        }
244
245        public void setRef(String ref) {
246                this.ref=ref;
247        }
248        public String getRef() {
249                return ref;
250        }
251}