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;
04:
05: import fit.Parse;
06: import fit.Fixture;
07: import java.io.*;
08:
09: public class FitFilter {
10:
11: public String input;
12:
13: public Parse tables;
14:
15: public Fixture fixture = new Fixture();
16:
17: public PrintWriter output;
18:
19: public static void main(String argv[]) {
20: new FitFilter().run(argv);
21: }
22:
23: public void run(String argv[]) {
24: args(argv);
25: process();
26: exit();
27: }
28:
29: public void process() {
30: try {
31: tables = new Parse(input);
32: fixture.doTables(tables);
33: } catch (Exception e) {
34: exception(e);
35: }
36: tables.print(output);
37: }
38:
39: public void args(String[] argv) {
40: if (argv.length != 0) {
41: System.err.println("usage: java fitnesse.FitFilter");
42: System.exit(-1);
43: }
44: try {
45: input = read();
46: output = new PrintWriter(System.out);
47: } catch (IOException e) {
48: System.err.println(e.getMessage());
49: System.exit(-1);
50: }
51: }
52:
53: protected String read() throws IOException {
54: StringBuffer buffer = new StringBuffer();
55: BufferedReader br = new BufferedReader(new InputStreamReader(
56: System.in));
57: String line;
58: while ((line = br.readLine()) != null)
59: buffer.append(line).append("\n");
60: return buffer.toString();
61: }
62:
63: protected void exception(Exception e) {
64: tables = new Parse("body",
65: "Unable to parse input. Input ignored.", null, null);
66: fixture.exception(tables, e);
67: }
68:
69: protected void exit() {
70: output.close();
71: System.exit(fixture.counts.wrong + fixture.counts.exceptions);
72: }
73:
74: }
|