|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| package net.sourceforge.pmd; |
|
5 |
| |
|
6 |
| public class ExternalRuleID { |
|
7 |
| |
|
8 |
| private String filename; |
|
9 |
| private String ruleName; |
|
10 |
| |
|
11 |
16
| public ExternalRuleID(String id) {
|
|
12 |
16
| int afterXML = id.indexOf(".xml") + 5;
|
|
13 |
16
| if (afterXML >= id.length()) {
|
|
14 |
0
| throw new RuntimeException("Unable to parse reference to external rule " + id + ". These references need to be in the form <rulesetname>/<rulename>, i.e., <rule ref=\"rulesets/unusedcode.xml/UnusedPrivateField\"/>");
|
|
15 |
| } |
|
16 |
16
| filename = id.substring(0, afterXML - 1);
|
|
17 |
16
| ruleName = id.substring(afterXML);
|
|
18 |
| } |
|
19 |
| |
|
20 |
16
| public String getFilename() {
|
|
21 |
16
| return filename;
|
|
22 |
| } |
|
23 |
| |
|
24 |
17
| public String getRuleName() {
|
|
25 |
17
| return ruleName;
|
|
26 |
| } |
|
27 |
| |
|
28 |
0
| public String toString() {
|
|
29 |
0
| return filename + "/" + ruleName;
|
|
30 |
| } |
|
31 |
| } |