01: /**
02: * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
03: */package net.sourceforge.pmd.renderers;
04:
05: import net.sourceforge.pmd.IRuleViolation;
06: import net.sourceforge.pmd.PMD;
07:
08: import java.io.IOException;
09: import java.io.Writer;
10: import java.util.Iterator;
11:
12: /**
13: * <P>A Renderer for running PMD via a TextPad 'tool'. <a href="http://www.textpad.com">TextPad</a> is a text editor by Helios Software Solutions.</P>
14: * <p/>
15: * <P>Output lines are in the form:</P>
16: * <p/>
17: * <P><CODE>pathtojavafile(line#, NameOfRule): Specific rule violation message</CODE></P>
18: * <p/>
19: * <P>For example:</P>
20: * <p/>
21: * <P><CODE>D:\java\pmd\src\src\net\sourceforge\pmd\renderers\TextPadRenderer.java(24, AtLeastOneConstructor): Each class should declare at least one constructor
22: * <br>D:\java\pmd\src\src\net\sourceforge\pmd\renderers\TextPadRenderer.java(26, VariableNamingConventionsRule): Variables should start with a lowercase character
23: * <br>D:\java\pmd\src\src\net\sourceforge\pmd\renderers\TextPadRenderer.java(31, ShortVariable): Avoid variables with short names</CODE></P>
24: *
25: * @author Jeff Epstein, based upon <a href="EmacsRenderer.html">EmacsRenderer</a>, Tuesday, September 23, 2003
26: */
27: public class TextPadRenderer extends OnTheFlyRenderer {
28:
29: public void start() throws IOException {
30: }
31:
32: public void renderFileViolations(Iterator<IRuleViolation> violations)
33: throws IOException {
34: Writer writer = getWriter();
35: StringBuffer buf = new StringBuffer();
36: while (violations.hasNext()) {
37: IRuleViolation rv = violations.next();
38: buf.setLength(0);
39: //Filename
40: buf.append(PMD.EOL).append(rv.getFilename() + "(");
41: //Line number
42: buf.append(Integer.toString(rv.getBeginLine())).append(
43: ", ");
44: //Name of violated rule
45: buf.append(rv.getRule().getName()).append("): ");
46: //Specific violation message
47: buf.append(rv.getDescription());
48: writer.write(buf.toString());
49: }
50: }
51:
52: public void end() throws IOException {
53: }
54: }
|