01: package fat;
02:
03: import fit.*;
04: import java.io.*;
05: import java.text.ParseException;
06:
07: public class StandardAnnotationFixture extends ColumnFixture {
08: public String OriginalHTML = "Text";
09: public String Annotation;
10: public String Text;
11:
12: public String Output() throws ParseException {
13: Parse parse = new Parse(OriginalHTML, new String[] { "td" });
14: Fixture testbed = new Fixture();
15:
16: if (Annotation.equals("right"))
17: testbed.right(parse);
18: if (Annotation.equals("wrong"))
19: testbed.wrong(parse, Text);
20: if (Annotation.equals("error"))
21: testbed.error(parse, Text);
22: if (Annotation.equals("info"))
23: testbed.info(parse, Text);
24: if (Annotation.equals("ignore"))
25: testbed.ignore(parse);
26:
27: return GenerateOutput(parse);
28: }
29:
30: public void doCell(Parse cell, int column) {
31: try {
32: if (column == 4) {
33: cell.body = RenderedOutput();
34: } else {
35: super .doCell(cell, column);
36: }
37: } catch (Exception e) {
38: exception(cell, e);
39: }
40: }
41:
42: public String RenderedOutput() throws ParseException {
43: return "<table border='1'><tr>" + Output() + "</tr></table>";
44: }
45:
46: // code smell note: copied from ParseFixture
47: private String GenerateOutput(Parse parse) {
48: StringWriter result = new StringWriter();
49: parse.print(new PrintWriter(result));
50: return result.toString().trim();
51: }
52: }
|