equal
deleted
inserted
replaced
56 { |
56 { |
57 if (aStr == null || aStr.length() == 0) |
57 if (aStr == null || aStr.length() == 0) |
58 { |
58 { |
59 return null; |
59 return null; |
60 } |
60 } |
61 String str = aStr.trim(); |
61 // Remove all invalid characters from string |
|
62 String str = normalizeVersion(aStr); |
|
63 if (str.length() == 0) |
|
64 { |
|
65 return null; |
|
66 } |
62 |
67 |
63 int major = 0; |
68 int major = 0; |
64 int minor = 0; |
69 int minor = 0; |
65 int micro = 0; |
70 int micro = 0; |
66 |
71 |
230 { |
235 { |
231 buf.append(".").append(getMicro()); |
236 buf.append(".").append(getMicro()); |
232 } |
237 } |
233 return buf.toString(); |
238 return buf.toString(); |
234 } |
239 } |
|
240 |
|
241 /** |
|
242 * Remove the illegal characters from version string, |
|
243 * for example "1.1 rev.2" becomes "1.1.2" |
|
244 */ |
|
245 private static String normalizeVersion(String aString) |
|
246 { |
|
247 StringBuffer buf = new StringBuffer(); |
|
248 int len = aString.length(); |
|
249 for (int ind = 0; ind < len; ind++) |
|
250 { |
|
251 char ch = aString.charAt(ind); |
|
252 if ((ch == '.') || Character.isDigit(ch)) |
|
253 { |
|
254 buf.append(ch); |
|
255 } |
|
256 } |
|
257 return buf.toString(); |
|
258 } |
235 } |
259 } |