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            
022            
023            public DumpTable(String highLightColor, String normalColor, String borderColor, String fontColor) {
024                    this.highLightColor=highLightColor;
025                    this.normalColor=normalColor;
026                    this.borderColor=borderColor;
027                    this.fontColor=fontColor;
028            }
029            public DumpTable(String highLightColor, String normalColor, String borderColor) {
030                    this(highLightColor, normalColor, borderColor, borderColor);
031            }
032            
033            /**
034             * @return returns if the box has content or not
035             */
036            public boolean isEmpty() {
037                    return rows.isEmpty();
038            }
039    
040            /**
041             * clear all data set in the HTMLBox
042             */
043            public void clear() {
044                    rows.clear();
045            }
046    
047        /**
048         * @param title sets the title of the HTML Box
049         */
050        public void setTitle(String title) {
051            this.title=title;
052        }
053        
054        /**
055         * returns the title of the DumpTable, if not defined returns null
056         * @return title of the DumpTable
057         */
058        public String getTitle() {
059            return title;
060        }
061    
062        /**
063         * @param comment sets the comment of the HTML Box
064         */
065        public void setComment(String comment) {
066            this.comment=comment;
067        }
068        
069        /**
070         * returns the comment of the DumpTable, if not defined returns null
071         * @return title of the DumpTable
072         */
073        public String getComment() {
074            return comment;
075        }
076            
077            /**
078             * @param width sets the With of the HTML Box, can be a number or a procentual value
079             */
080            public void setWidth(String width) {
081                    this.width=width;
082            }
083    
084            /**
085             * @param height sets the Height of the HTML Box, can be a number or a procentual value
086             */
087            public void setHeight(String height) {
088                    this.height=height;
089            }
090    
091    
092            /**
093             * @return the borderColor
094             */
095            public String getBorderColor() {
096                    return borderColor;
097            }
098    
099            /**
100             * @param borderColor the borderColor to set
101             */
102            public void setBorderColor(String borderColor) {
103                    this.borderColor = borderColor;
104            }
105    
106            /**
107             * @return the fontColor
108             */
109            public String getFontColor() {
110                    return fontColor;
111            }
112    
113            /**
114             * @param fontColor the fontColor to set
115             */
116            public void setFontColor(String fontColor) {
117                    this.fontColor = fontColor;
118            }
119    
120            /**
121             * @return the highLightColor
122             */
123            public String getHighLightColor() {
124                    return highLightColor;
125            }
126    
127            /**
128             * @param highLightColor the highLightColor to set
129             */
130            public void setHighLightColor(String highLightColor) {
131                    this.highLightColor = highLightColor;
132            }
133    
134            /**
135             * @return the normalColor
136             */
137            public String getNormalColor() {
138                    return normalColor;
139            }
140    
141            /**
142             * @param normalColor the normalColor to set
143             */
144            public void setNormalColor(String normalColor) {
145                    this.normalColor = normalColor;
146            }
147    
148            /**
149             * @return the height
150             */
151            public String getHeight() {
152                    return height;
153            }
154    
155            /**
156             * @return the rows
157             */
158            public DumpRow[] getRows() {
159                    return (DumpRow[])rows.toArray(new DumpRow[rows.size()]);
160            }
161    
162            public void appendRow(DumpRow row) {
163                    rows.add(row);
164            }
165            
166            public void appendRow(int highlightType, DumpData item1) {
167                    appendRow(new DumpRow(highlightType,new DumpData[]{item1}));
168            }
169    
170        public void appendRow(int highlightType, DumpData item1, DumpData item2) {
171            appendRow(new DumpRow(highlightType,new DumpData[]{item1,item2}));
172            }
173    
174            public void appendRow(int highlightType, DumpData item1, DumpData item2, DumpData item3) {
175                    appendRow(new DumpRow(highlightType,new DumpData[]{item1,item2,item3}));
176            }
177            
178            public void appendRow(int highlightType, DumpData item1, DumpData item2, DumpData item3,DumpData item4) {
179                    appendRow(new DumpRow(highlightType,new DumpData[]{item1,item2,item3,item4}));
180            }
181            
182            public void appendRow(int highlightType, DumpData item1, DumpData item2, DumpData item3,DumpData item4, DumpData item5) {
183                    appendRow(new DumpRow(highlightType,new DumpData[]{item1,item2,item3,item4,item5}));
184            }
185    
186            public void appendRow(int highlightType, DumpData item1, DumpData item2, DumpData item3,DumpData item4, DumpData item5, DumpData item6) {
187                    appendRow(new DumpRow(highlightType,new DumpData[]{item1,item2,item3,item4,item5,item6}));
188            }
189            
190    
191            public void prependRow(DumpRow row) {
192                    rows.add(0, row);
193            }
194    
195            /**
196             * @return the width
197             */
198            public String getWidth() {
199                    return width;
200            }
201    }