|
1 |
| |
|
2 |
| package net.sourceforge.pmd; |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| public final class SourceType implements Comparable { |
|
10 |
| public static final SourceType JAVA_13 = new SourceType("java 1.3"); |
|
11 |
| public static final SourceType JAVA_14 = new SourceType("java 1.4"); |
|
12 |
| public static final SourceType JAVA_15 = new SourceType("java 1.5"); |
|
13 |
| public static final SourceType JAVA_16 = new SourceType("java 1.6"); |
|
14 |
| public static final SourceType JSP = new SourceType("jsp"); |
|
15 |
| |
|
16 |
| private static SourceType[] sourceTypes = new SourceType[]{JAVA_13, JAVA_14, JAVA_15, JAVA_16, JSP}; |
|
17 |
| |
|
18 |
| private String id; |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
1130
| private SourceType(String id) {
|
|
24 |
1130
| this.id = id;
|
|
25 |
| } |
|
26 |
| |
|
27 |
6217
| public String getId() {
|
|
28 |
6217
| return id;
|
|
29 |
| } |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
40
| public static SourceType getSourceTypeForId(String id) {
|
|
37 |
163
| for (int i = 0; i < sourceTypes.length; i++) {
|
|
38 |
163
| if (sourceTypes[i].getId().equalsIgnoreCase(id)) {
|
|
39 |
40
| return sourceTypes[i];
|
|
40 |
| } |
|
41 |
| } |
|
42 |
0
| return null;
|
|
43 |
| } |
|
44 |
| |
|
45 |
3
| public boolean equals(Object other) {
|
|
46 |
3
| if (other instanceof SourceType) {
|
|
47 |
3
| return ((SourceType) other).getId().equals(getId());
|
|
48 |
| } |
|
49 |
| |
|
50 |
0
| return false;
|
|
51 |
| } |
|
52 |
| |
|
53 |
6006
| public int hashCode() {
|
|
54 |
6006
| return getId().hashCode();
|
|
55 |
| } |
|
56 |
| |
|
57 |
21
| public int compareTo(Object other) {
|
|
58 |
21
| return getId().compareTo(((SourceType) other).getId());
|
|
59 |
| } |
|
60 |
| |
|
61 |
0
| public String toString() {
|
|
62 |
0
| return "SourceType [" + getId() + "]";
|
|
63 |
| } |
|
64 |
| } |