01: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
02: // Released under the terms of the GNU General Public License version 2 or later.
03: package fitnesse.wikitext.widgets;
04:
05: import java.util.regex.Matcher;
06: import java.util.regex.Pattern;
07:
08: public class TableRowWidget extends ParentWidget {
09: private static final Pattern pattern = Pattern
10: .compile("\\|([^\\|\n\r]*)");
11:
12: private TableWidget parentTable;
13:
14: private boolean isLiteral;
15:
16: public TableRowWidget(TableWidget parentTable, String text,
17: boolean isLiteral) throws Exception {
18: super (parentTable);
19: this .parentTable = parentTable;
20: this .isLiteral = isLiteral;
21: addCells(text);
22: }
23:
24: public int getColumns() {
25: return numberOfChildren();
26: }
27:
28: public TableWidget getParentTable() {
29: return parentTable;
30: }
31:
32: public String render() throws Exception {
33: StringBuffer html = new StringBuffer("<tr>");
34: html.append(childHtml()).append("</tr>\n");
35: return html.toString();
36: }
37:
38: private void addCells(String text) throws Exception {
39: Matcher match = pattern.matcher(text);
40: if (match.find()) {
41: new TableCellWidget(this , match.group(1), isLiteral);
42: addCells(text.substring(match.end()));
43: }
44: }
45: }
|