Source code: com/lutris/html/HtmlTableRow.java
1 /*
2 * Enhydra Java Application Server Project
3 *
4 * The contents of this file are subject to the Enhydra Public License
5 * Version 1.1 (the "License"); you may not use this file except in
6 * compliance with the License. You may obtain a copy of the License on
7 * the Enhydra web site ( http://www.enhydra.org/ ).
8 *
9 * Software distributed under the License is distributed on an "AS IS"
10 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11 * the License for the specific terms governing rights and limitations
12 * under the License.
13 *
14 * The Initial Developer of the Enhydra Application Server is Lutris
15 * Technologies, Inc. The Enhydra Application Server and portions created
16 * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17 * All Rights Reserved.
18 *
19 * Contributor(s):
20 *
21 * $Id: HtmlTableRow.java,v 1.8.12.1 2000/10/19 17:58:53 jasona Exp $
22 */
23
24
25
26
27
28 package com.lutris.html;
29
30 import java.util.Vector;
31 import java.util.Enumeration;
32
33 /**
34 * This utility class is used to compose a row within a
35 * HTML table.
36 *
37 * @see HtmlTable
38 * @see HtmlTableDataCell
39 * @see HtmlTableHeaderCell
40 * @author Kyle Clark
41 * @author Paul Morgan
42 * @version 1.0 (File $Revision: 1.8.12.1 $)
43 */
44 public class HtmlTableRow {
45
46 public static final int ALIGN_LEFT = 1;
47 public static final int ALIGN_CENTER = 2;
48 public static final int ALIGN_RIGHT = 3;
49 public static final int VALIGN_TOP = 1;
50 public static final int VALIGN_MIDDLE = 2;
51 public static final int VALIGN_BOTTOM = 3;
52
53 private String caption = null;
54 private String align = null;
55 private String valign = null;
56 private Vector row = new Vector();
57 private int colSpan = 0;
58 private int rowSpan = 0;
59 private String bgColor = null;
60
61 public HtmlTableRow()
62 {
63 // noop
64 }
65
66 public HtmlTableRow(HtmlTableCell td)
67 {
68 addCell(td);
69 }
70
71 public HtmlTableRow(String td)
72 {
73 addCell(td);
74 }
75
76 public void addCell(HtmlTableCell td)
77 {
78 row.addElement(td);
79 }
80
81 public void addCell(String td)
82 {
83 row.addElement(td);
84 }
85
86 public void setHorizontalAlignment(int alignment)
87 {
88 switch (alignment) {
89 case ALIGN_CENTER:
90 this.align = "CENTER";
91 break;
92 case ALIGN_RIGHT:
93 this.align = "RIGHT";
94 break;
95 default:
96 this.align = "LEFT";
97 break;
98 }
99 }
100
101 public void setVerticalAlignment(int alignment)
102 {
103 switch (alignment) {
104 case VALIGN_TOP:
105 this.valign = "TOP";
106 break;
107 case VALIGN_MIDDLE:
108 this.valign = "MIDDLE";
109 break;
110 default:
111 this.valign = "BOTTOM";
112 break;
113 }
114 }
115
116 public void setRowSpan(int rowSpan)
117 {
118 if (rowSpan > 0)
119 this.rowSpan = rowSpan;
120 }
121
122 public void setColSpan(int colSpan)
123 {
124 if (colSpan > 0)
125 this.colSpan = colSpan;
126 }
127
128 public void setBackgroundColor(String bgColor)
129 {
130 this.bgColor = bgColor;
131 }
132
133 public String toString()
134 {
135 StringBuffer html = new StringBuffer();
136
137 html.append("<TR");
138 if (align != null)
139 html.append(" ALIGN=" + align);
140 if (valign != null)
141 html.append(" VALIGN=" + valign);
142 if (colSpan > 0)
143 html.append(" COLSPAN=" + colSpan);
144 if (rowSpan > 0)
145 html.append(" ROWSPAN=" + rowSpan);
146 if (bgColor != null)
147 html.append(" BGCOLOR=" + bgColor);
148 html.append(">\n");
149
150 Enumeration e = row.elements();
151 while (e.hasMoreElements()) {
152 html.append(e.nextElement().toString());
153 }
154 html.append("</TR>\n");
155
156 return html.toString();
157 }
158 }