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