View Javadoc
1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.lang.rule;
5   
6   import java.util.List;
7   import java.util.Map;
8   import java.util.Set;
9   
10  import net.sourceforge.pmd.PropertyDescriptor;
11  import net.sourceforge.pmd.PropertySource;
12  import net.sourceforge.pmd.Rule;
13  import net.sourceforge.pmd.RuleContext;
14  import net.sourceforge.pmd.RulePriority;
15  import net.sourceforge.pmd.lang.Language;
16  import net.sourceforge.pmd.lang.LanguageVersion;
17  import net.sourceforge.pmd.lang.ParserOptions;
18  import net.sourceforge.pmd.lang.ast.Node;
19  
20  /**
21   * Base class for Rule implementations which delegate to another Rule instance.
22   */
23  public abstract class AbstractDelegateRule implements Rule {
24  
25  	private Rule rule;
26  
27  	public void setRule(Rule rule) {
28  		this.rule = rule;
29  	}
30  
31  	public Rule getRule() {
32  		return rule;
33  	}
34  
35  	public Language getLanguage() {
36  		return rule.getLanguage();
37  	}
38  
39  	public void setLanguage(Language language) {
40  		rule.setLanguage(language);
41  	}
42  
43  	public LanguageVersion getMinimumLanguageVersion() {
44  		return rule.getMinimumLanguageVersion();
45  	}
46  
47  	public void setMinimumLanguageVersion(LanguageVersion minimumlanguageVersion) {
48  		rule.setMinimumLanguageVersion(minimumlanguageVersion);
49  	}
50  
51  	public void setMaximumLanguageVersion(LanguageVersion maximumlanguageVersion) {
52  		rule.setMaximumLanguageVersion(maximumlanguageVersion);
53  	}
54  
55  	public LanguageVersion getMaximumLanguageVersion() {
56  		return rule.getMaximumLanguageVersion();
57  	}
58  
59  	public boolean isDeprecated() {
60  		return rule.isDeprecated();
61  	}
62  
63  	/**
64  	 * @see PropertySource#dysfunctionReason()
65  	 */
66  	public String dysfunctionReason() {
67  		return rule.dysfunctionReason();
68  	}
69  
70  	public Set<PropertyDescriptor<?>> ignoredProperties() {
71  		return rule.ignoredProperties();
72  	}
73  
74  	public void setDeprecated(boolean deprecated) {
75  		rule.setDeprecated(deprecated);
76  	}
77  
78  	public String getName() {
79  		return rule.getName();
80  	}
81  
82  	public void setName(String name) {
83  		rule.setName(name);
84  	}
85  
86  	public String getSince() {
87  		return rule.getSince();
88  	}
89  
90  	public void setSince(String since) {
91  		rule.setSince(since);
92  	}
93  
94  	public String getRuleClass() {
95  		return rule.getRuleClass();
96  	}
97  
98  	public void setRuleClass(String ruleClass) {
99  		rule.setRuleClass(ruleClass);
100 	}
101 
102 	public String getRuleSetName() {
103 		return rule.getRuleSetName();
104 	}
105 
106 	public void setRuleSetName(String name) {
107 		rule.setRuleSetName(name);
108 	}
109 
110 	public String getMessage() {
111 		return rule.getMessage();
112 	}
113 
114 	public void setMessage(String message) {
115 		rule.setMessage(message);
116 	}
117 
118 	public String getDescription() {
119 		return rule.getDescription();
120 	}
121 
122 	public void setDescription(String description) {
123 		rule.setDescription(description);
124 	}
125 
126 	public List<String> getExamples() {
127 		return rule.getExamples();
128 	}
129 
130 	public void addExample(String example) {
131 		rule.addExample(example);
132 	}
133 
134 	public String getExternalInfoUrl() {
135 		return rule.getExternalInfoUrl();
136 	}
137 
138 	public void setExternalInfoUrl(String url) {
139 		rule.setExternalInfoUrl(url);
140 	}
141 
142 	public RulePriority getPriority() {
143 		return rule.getPriority();
144 	}
145 
146 	public void setPriority(RulePriority priority) {
147 		rule.setPriority(priority);
148 	}
149 
150 	public ParserOptions getParserOptions() {
151 	    return rule.getParserOptions();
152 	}
153 
154 	public void definePropertyDescriptor(PropertyDescriptor<?> propertyDescriptor) throws IllegalArgumentException {
155 	    rule.definePropertyDescriptor(propertyDescriptor);
156 	}
157 
158 	public PropertyDescriptor<?> getPropertyDescriptor(String name) {
159 	    return rule.getPropertyDescriptor(name);
160 	}
161 
162 	public List<PropertyDescriptor<?>> getPropertyDescriptors() {
163 	    return rule.getPropertyDescriptors();
164 	}
165 
166 	public <T> T getProperty(PropertyDescriptor<T> propertyDescriptor) {
167 	    return rule.getProperty(propertyDescriptor);
168 	}
169 
170 	public <T> void setProperty(PropertyDescriptor<T> propertyDescriptor, T value) {
171 	    rule.setProperty(propertyDescriptor, value);
172 	}
173 
174 	public Map<PropertyDescriptor<?>, Object> getPropertiesByPropertyDescriptor() {
175 	    return rule.getPropertiesByPropertyDescriptor();
176 	}
177 
178 	public void setUsesDFA() {
179 		 rule.setUsesDFA();
180 	 }
181 
182 	 public boolean usesDFA() {
183 		 return rule.usesDFA();
184 	 }
185 
186 	 public void setUsesTypeResolution() {
187 		 rule.setUsesTypeResolution();
188 	 }
189 
190 	 public boolean usesTypeResolution() {
191 		 return rule.usesTypeResolution();
192 	 }
193 
194 	 public boolean usesRuleChain() {
195 		 return rule.usesRuleChain();
196 	 }
197 
198 	 public List<String> getRuleChainVisits() {
199 		 return rule.getRuleChainVisits();
200 	 }
201 
202 	 public void addRuleChainVisit(Class<? extends Node> nodeClass) {
203 		 rule.addRuleChainVisit(nodeClass);
204 	 }
205 
206 	 public void addRuleChainVisit(String astNodeName) {
207 		 rule.addRuleChainVisit(astNodeName);
208 	 }
209 
210 	 public void start(RuleContext ctx) {
211 		 rule.start(ctx);
212 	 }
213 
214 	 public void apply(List<? extends Node> nodes, RuleContext ctx) {
215 		 rule.apply(nodes, ctx);
216 	 }
217 
218 	 public void end(RuleContext ctx) {
219 		 rule.end(ctx);
220 	 }
221 
222     /**
223      * @see Rule#hasDescriptor(PropertyDescriptor)
224      */
225     public boolean hasDescriptor(PropertyDescriptor<?> descriptor) {
226     	return rule.hasDescriptor(descriptor);
227     }
228 }