001 /**
002 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
003 */
004 package net.sourceforge.pmd.renderers;
005
006 import java.io.Writer;
007 import java.util.LinkedHashMap;
008 import java.util.Map;
009 import java.util.Properties;
010
011 /**
012 * Abstract base class for {@link Renderer} implementations.
013 */
014 public abstract class AbstractRenderer implements Renderer {
015
016 protected String name;
017 protected String description;
018 protected Map<String, String> propertyDefinitions = new LinkedHashMap<String, String>();
019 protected Properties properties;
020 protected boolean showSuppressedViolations = true;
021 protected Writer writer;
022
023 public AbstractRenderer(String name, String description, Properties properties) {
024 this.name = name;
025 this.description = description;
026 this.properties = properties;
027 }
028
029 /**
030 * {@inheritDoc}
031 */
032 public String getName() {
033 return name;
034 }
035
036 /**
037 * {@inheritDoc}
038 */
039 public void setName(String name) {
040 this.name = name;
041 }
042
043 /**
044 * {@inheritDoc}
045 */
046 public String getDescription() {
047 return description;
048 }
049
050 /**
051 * {@inheritDoc}
052 */
053 public void setDescription(String description) {
054 this.description = description;
055 }
056
057 /**
058 * {@inheritDoc}
059 */
060 public Map<String, String> getPropertyDefinitions() {
061 return propertyDefinitions;
062 }
063
064 /**
065 * Define a property.
066 * @param name The property name.
067 * @param description The description of the property.
068 */
069 protected void defineProperty(String name, String description) {
070 propertyDefinitions.put(name, description);
071 }
072
073 /**
074 * {@inheritDoc}
075 */
076 public boolean isShowSuppressedViolations() {
077 return showSuppressedViolations;
078 }
079
080 /**
081 * {@inheritDoc}
082 */
083 public void setShowSuppressedViolations(boolean showSuppressedViolations) {
084 this.showSuppressedViolations = showSuppressedViolations;
085 }
086
087 /**
088 * {@inheritDoc}
089 */
090 public void setWriter(Writer writer) {
091 this.writer = writer;
092 }
093
094 /**
095 * {@inheritDoc}
096 */
097 public Writer getWriter() {
098 return writer;
099 }
100 }
|