1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sourceforge.javadpkg.impl;
20
21 import java.util.Map;
22 import java.util.TreeMap;
23
24 import net.sourceforge.javadpkg.ChangeLogUrgency;
25 import net.sourceforge.javadpkg.ChangeLogUrgencyParser;
26 import net.sourceforge.javadpkg.Context;
27 import net.sourceforge.javadpkg.ParseException;
28
29
30
31
32
33
34
35
36
37
38 public class ChangeLogUrgencyParserImpl implements ChangeLogUrgencyParser {
39
40
41
42 private Map<String, ChangeLogUrgency> urgency;
43
44
45
46
47
48
49
50 public ChangeLogUrgencyParserImpl() {
51 super();
52
53 this.urgency = new TreeMap<>();
54 this.addUrgency("low");
55 this.addUrgency("medium");
56 this.addUrgency("high");
57 this.addUrgency("emergency");
58 this.addUrgency("critical");
59 }
60
61
62
63
64
65
66
67
68
69
70 private void addUrgency(String text) {
71 this.urgency.put(text.toLowerCase(), new ChangeLogUrgencyImpl(text));
72 }
73
74
75 @Override
76 public ChangeLogUrgency parseChangeLogUrgency(String value, Context context) throws ParseException {
77 ChangeLogUrgency urgency;
78
79
80 if (value == null)
81 throw new IllegalArgumentException("Argument value is null.");
82 if (context == null)
83 throw new IllegalArgumentException("Argument context is null.");
84
85 urgency = this.urgency.get(value.toLowerCase());
86 if (urgency == null) {
87 urgency = new ChangeLogUrgencyImpl(value);
88 context.addWarning(new ChangeLogUrgencyUnsupportedWarning(value));
89 }
90
91 return urgency;
92 }
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111 private class ChangeLogUrgencyImpl implements ChangeLogUrgency {
112
113
114
115 private String text;
116
117
118
119
120
121
122
123
124
125
126 public ChangeLogUrgencyImpl(String text) {
127 super();
128
129 this.text = text;
130 }
131
132
133 @Override
134 public String getText() {
135 return this.text;
136 }
137
138
139 }
140
141
142 }