KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > incava > analysis > TerseReport


1 package org.incava.analysis;
2
3 import java.io.*;
4 import java.util.*;
5 import net.sourceforge.pmd.ast.Token;
6
7
8 /**
9  * Reports errors in a single line, AKA the format expected by Emacs (!c).
10  */

11 public class TerseReport extends Report
12 {
13     /**
14      * Creates a terse report for the given writer.
15      *
16      * @param writer The writer associated with this report.
17      */

18     public TerseReport(Writer writer)
19     {
20         super(writer);
21     }
22
23     /**
24      * Creates a terse report for the given output stream.
25      *
26      * @param os The output stream associated with this report.
27      */

28     public TerseReport(OutputStream os)
29     {
30         super(os);
31     }
32
33     /**
34      * Creates a terse report for the given writer, and a string source.
35      *
36      * @param writer The writer associated with this report.
37      * @param source The source code to which this report applies.
38      */

39     public TerseReport(Writer writer, String JavaDoc source)
40     {
41         super(writer, source);
42     }
43
44     /**
45      * Creates a terse report for the given writer, and a file source.
46      *
47      * @param writer The writer associated with this report.
48      * @param file The file, containing source code, to which this report applies.
49      */

50     public TerseReport(Writer writer, File file)
51     {
52         super(writer, file);
53     }
54
55     /**
56      * Creates a terse report for the given output stream, and string source.
57      *
58      * @param os The output stream associated with this report.
59      * @param source The source code to which this report applies.
60      */

61     public TerseReport(OutputStream os, String JavaDoc source)
62     {
63         super(os, source);
64     }
65
66     /**
67      * Creates a terse report for the given output stream, and file.
68      *
69      * @param os The output stream associated with this report.
70      * @param file The file, containing source code, to which this report applies.
71      */

72     public TerseReport(OutputStream os, File file)
73     {
74         super(os, file);
75     }
76
77     /**
78      * Returns the given violation, in single-line format. For example:
79      *
80      * <pre>
81      * TerseReport.java:77:22:77:29: Undocumented protected method
82      * </pre>
83      *
84      * @param violation The violation to represent as a single-line violation.
85      * @return The violation, in single-line format.
86      */

87     protected String JavaDoc toString(Violation violation)
88     {
89         return (fileName + ":" +
90                 violation.getBeginLine() + ":" + violation.getBeginColumn() + ":" +
91                 violation.getEndLine() + ":" + violation.getEndColumn() + ": " +
92                 violation.getMessage() + System.getProperty("line.separator"));
93     }
94
95 }
96
Popular Tags