KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > pmd > ExternalRuleID


1 /**
2  * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3  */

4 package net.sourceforge.pmd;
5
6 public class ExternalRuleID {
7
8     private String JavaDoc filename;
9     private String JavaDoc ruleName;
10
11     public ExternalRuleID(String JavaDoc id) {
12         int afterXML = id.indexOf(".xml") + 5;
13         if (afterXML >= id.length()) {
14             throw new RuntimeException JavaDoc("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         filename = id.substring(0, afterXML - 1);
17         ruleName = id.substring(afterXML);
18     }
19
20     public String JavaDoc getFilename() {
21         return filename;
22     }
23
24     public String JavaDoc getRuleName() {
25         return ruleName;
26     }
27
28     public String JavaDoc toString() {
29         return filename + "/" + ruleName;
30     }
31 }
32
Popular Tags