1
2
3
4 package net.sourceforge.pmd.renderers;
5
6 import java.io.IOException;
7 import java.io.Writer;
8 import java.util.LinkedHashMap;
9 import java.util.Map;
10
11 import net.sourceforge.pmd.AbstractPropertySource;
12 import net.sourceforge.pmd.lang.rule.properties.StringProperty;
13 import net.sourceforge.pmd.util.IOUtil;
14
15
16
17
18 public abstract class AbstractRenderer extends AbstractPropertySource implements Renderer {
19
20 protected String name;
21 protected String description;
22
23 @Deprecated
24 protected Map<String, String> propertyDefinitions = new LinkedHashMap<String, String>();
25 protected boolean showSuppressedViolations = true;
26 protected Writer writer;
27
28 public AbstractRenderer(String name, String description) {
29 this.name = name;
30 this.description = description;
31 }
32
33
34
35
36 public String getName() {
37 return name;
38 }
39
40
41
42
43 public void setName(String name) {
44 this.name = name;
45 }
46
47
48
49
50 public String getDescription() {
51 return description;
52 }
53
54
55
56
57 public void setDescription(String description) {
58 this.description = description;
59 }
60
61
62
63
64 @Deprecated
65 public Map<String, String> getPropertyDefinitions() {
66 return propertyDefinitions;
67 }
68
69
70
71
72
73
74 @Deprecated
75 protected void defineProperty(String name, String description) {
76 StringProperty propertyDescriptor = new StringProperty(name, description, null, 0);
77 definePropertyDescriptor(propertyDescriptor);
78 propertyDefinitions.put(name, description);
79 }
80
81
82
83
84 public boolean isShowSuppressedViolations() {
85 return showSuppressedViolations;
86 }
87
88
89
90
91 public void setShowSuppressedViolations(boolean showSuppressedViolations) {
92 this.showSuppressedViolations = showSuppressedViolations;
93 }
94
95
96
97
98 public void setWriter(Writer writer) {
99 this.writer = writer;
100 }
101
102
103
104
105 public Writer getWriter() {
106 return writer;
107 }
108
109 public void flush() {
110 try {
111 this.writer.flush();
112 } catch (IOException e) {
113 throw new IllegalStateException(e);
114 } finally {
115 IOUtil.closeQuietly(writer);
116 }
117 }
118 }