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