01: package org.acm.seguin.pmd;
02:
03: public class ExternalRuleID {
04:
05: private String filename;
06: private String ruleName;
07:
08: public ExternalRuleID(String id) {
09: int afterXML = id.indexOf(".xml") + 5;
10: if (afterXML >= id.length()) {
11: throw new RuntimeException(
12: "Unable to parse reference to external rule "
13: + id
14: + ". These references need to be in the form <rulesetname>/<rulename>, i.e., <rule ref=\"rulesets/unusedcode.xml/UnusedPrivateField\"/>");
15: }
16: filename = id.substring(0, afterXML - 1);
17: ruleName = id.substring(afterXML);
18: }
19:
20: public String getFilename() {
21: return filename;
22: }
23:
24: public String getRuleName() {
25: return ruleName;
26: }
27:
28: public String toString() {
29: return filename + "/" + ruleName;
30: }
31: }
|