01: package fat;
02:
03: import java.text.ParseException;
04: import fit.*;
05:
06: public class FixtureNameFixture extends ColumnFixture {
07: public String Table;
08:
09: public String FixtureName() throws Exception {
10: Parse tableParse = GenerateTableParse(Table);
11:
12: String result = fixtureName(tableParse).text();
13: if (result.equals(""))
14: return "(missing)";
15: return result;
16: }
17:
18: private Parse GenerateTableParse(String table)
19: throws ParseException {
20: String[] rows = table.split("\n");
21: return new Parse("table", null, GenerateRowParses(rows, 0),
22: null);
23: }
24:
25: private Parse GenerateRowParses(String[] rows, int rowIndex) {
26: if (rowIndex >= rows.length)
27: return null;
28:
29: String[] cells = rows[rowIndex].split("\\]\\s*\\[");
30: if (cells.length != 0) {
31: cells[0] = cells[0].substring(1); // strip beginning '['
32: int lastCell = cells.length - 1;
33: cells[lastCell] = cells[lastCell].replaceAll("\\]$", ""); // strip ending ']'
34: }
35:
36: return new Parse("tr", null, GenerateCellParses(cells, 0),
37: GenerateRowParses(rows, rowIndex + 1));
38: }
39:
40: private Parse GenerateCellParses(String[] cells, int cellIndex) {
41: if (cellIndex >= cells.length)
42: return null;
43:
44: return new Parse("td", cells[cellIndex], null,
45: GenerateCellParses(cells, cellIndex + 1));
46: }
47: }
|