1
2
3
4
5
6
7
8
9
10
11
12 package org.displaytag.model;
13
14 import java.util.ArrayList;
15 import java.util.List;
16 import java.util.Map;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.apache.commons.lang.builder.ToStringBuilder;
20 import org.apache.commons.lang.builder.ToStringStyle;
21 import org.displaytag.util.HtmlAttributeMap;
22 import org.displaytag.util.MultipleHtmlAttribute;
23 import org.displaytag.util.TagConstants;
24
25
26
27
28
29
30
31 public class Row
32 {
33
34
35
36
37 private Object rowObject;
38
39
40
41
42 private List staticCells;
43
44
45
46
47 private int rowNumber;
48
49
50
51
52 private TableModel tableModel;
53
54
55
56
57
58
59 public Row(Object object, int number)
60 {
61 this.rowObject = object;
62 this.rowNumber = number;
63 this.staticCells = new ArrayList();
64 }
65
66
67
68
69
70 public void setRowNumber(int number)
71 {
72 this.rowNumber = number;
73 }
74
75
76
77
78
79 public int getRowNumber()
80 {
81 return this.rowNumber;
82 }
83
84
85
86
87
88 public void addCell(Cell cell)
89 {
90 this.staticCells.add(cell);
91 }
92
93
94
95
96
97 public List getCellList()
98 {
99 return this.staticCells;
100 }
101
102
103
104
105
106 public Object getObject()
107 {
108 return this.rowObject;
109 }
110
111
112
113
114
115
116 public ColumnIterator getColumnIterator(List columns)
117 {
118 return new ColumnIterator(columns, this);
119 }
120
121
122
123
124
125 protected void setParentTable(TableModel table)
126 {
127 this.tableModel = table;
128 }
129
130
131
132
133
134 protected TableModel getParentTable()
135 {
136 return this.tableModel;
137 }
138
139
140
141
142
143 public String getOpenTag()
144 {
145 Map rowAttributes = new HtmlAttributeMap();
146
147 MultipleHtmlAttribute cssAttribute = new MultipleHtmlAttribute(this.tableModel.getProperties().getCssRow(
148 this.rowNumber));
149
150 if (this.tableModel.getTableDecorator() != null)
151 {
152 try
153 {
154 String addStyle = this.tableModel.getTableDecorator().addRowClass();
155
156 if (StringUtils.isNotBlank(addStyle))
157 {
158 cssAttribute.addAttributeValue(addStyle);
159 }
160
161 String id = this.tableModel.getTableDecorator().addRowId();
162 if (StringUtils.isNotBlank(id))
163 {
164 rowAttributes.put(TagConstants.ATTRIBUTE_ID, id);
165 }
166 }
167 catch (NoSuchMethodError e)
168 {
169
170
171
172 }
173 }
174
175 if (!cssAttribute.isEmpty())
176 {
177 rowAttributes.put(TagConstants.ATTRIBUTE_CLASS, cssAttribute);
178 }
179
180 StringBuffer tag = new StringBuffer();
181 tag.append(TagConstants.TAG_OPEN);
182 tag.append(TagConstants.TAGNAME_ROW);
183
184 tag.append(rowAttributes.toString());
185
186 tag.append(TagConstants.TAG_CLOSE);
187
188 return tag.toString();
189 }
190
191
192
193
194
195 public String getCloseTag()
196 {
197 return TagConstants.TAG_TR_CLOSE;
198 }
199
200
201
202
203 public String toString()
204 {
205 return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
206 .append("rowNumber", this.rowNumber)
207 .append("rowObject", this.rowObject)
208 .toString();
209 }
210 }