|
|||||||||||||||||||
| This license of Clover is provided to support the development of JBind only. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover. | |||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| Countries.java | 33,3% | 75% | 0% | 55% |
|
||||||||||||||
| 1 |
/* |
|
| 2 |
* JBind |
|
| 3 |
* |
|
| 4 |
* Copyright (c) by Stefan Wachter. All rights reserved. |
|
| 5 |
* |
|
| 6 |
* Usage, modification, and redistribution is subject to license terms that are |
|
| 7 |
* available at 'http://www.jbind.org'. The JBind license is like the |
|
| 8 |
* 'Apache Software License V 1.1'. |
|
| 9 |
*/ |
|
| 10 |
package org.jbind.base; |
|
| 11 |
|
|
| 12 |
import java.io.BufferedReader; |
|
| 13 |
import java.io.InputStreamReader; |
|
| 14 |
import java.util.HashMap; |
|
| 15 |
import java.util.Map; |
|
| 16 |
|
|
| 17 |
/** |
|
| 18 |
* Contains country codes according to ISO 3166 alpha-2. |
|
| 19 |
* The codes are set up by reading in the files "countries.txt". |
|
| 20 |
*/ |
|
| 21 |
public class Countries {
|
|
| 22 |
|
|
| 23 |
public static Map ourCountries = new HashMap(); |
|
| 24 |
|
|
| 25 | 0 |
public static boolean contains(String aString) {
|
| 26 | 0 |
return null != ourCountries.get(aString); |
| 27 |
} |
|
| 28 |
|
|
| 29 |
static {
|
|
| 30 | 3 |
BufferedReader r = new BufferedReader(new InputStreamReader(Countries.class.getResourceAsStream("countries.txt")));
|
| 31 | 3 |
try {
|
| 32 | 3 |
String line; |
| 33 | ? |
while (null != (line = r.readLine())) {
|
| 34 | 717 |
if (line.startsWith("#")) {
|
| 35 | 0 |
continue; |
| 36 |
} |
|
| 37 | 717 |
int idx = line.lastIndexOf(';');
|
| 38 | 717 |
if (idx >= 0) {
|
| 39 | 717 |
String code = line.substring(idx + 1).trim().toUpperCase(); |
| 40 | 717 |
ourCountries.put(code, line.substring(0, idx)); |
| 41 |
} |
|
| 42 |
} |
|
| 43 |
} catch (Exception e) {
|
|
| 44 | 0 |
e.printStackTrace(); |
| 45 |
} |
|
| 46 |
} |
|
| 47 |
|
|
| 48 | 0 |
private Countries() {}
|
| 49 |
|
|
| 50 |
} |
|
| 51 |
|
|
||||||||||