01: package fat;
02:
03: import fit.*;
04: import java.text.*;
05: import java.io.*;
06:
07: public class DocumentParseFixture extends ColumnFixture {
08: public String HTML;
09: public String Note; // non-functional
10:
11: public String Output() throws ParseException {
12: return GenerateOutput(new Parse(HTML));
13: }
14:
15: public String Structure() throws ParseException {
16: return dumpTables(new Parse(HTML));
17: }
18:
19: private String GenerateOutput(Parse parse) {
20: StringWriter result = new StringWriter();
21: parse.print(new PrintWriter(result));
22: return result.toString();
23: }
24:
25: private String dumpTables(Parse table) {
26: String result = "";
27: String separator = "";
28: while (table != null) {
29: result += separator;
30: result += dumpRows(table.parts);
31: separator = "\n----\n";
32: table = table.more;
33: }
34: return result;
35: }
36:
37: private String dumpRows(Parse row) {
38: String result = "";
39: String separator = "";
40: while (row != null) {
41: result += separator;
42: result += dumpCells(row.parts);
43: separator = "\n";
44: row = row.more;
45: }
46: return result;
47: }
48:
49: private String dumpCells(Parse cell) {
50: String result = "";
51: String separator = "";
52: while (cell != null) {
53: result += separator;
54: result += "[" + cell.body + "]";
55: separator = " ";
56: cell = cell.more;
57: }
58: return result;
59: }
60: }
|