1 19 20 package jxl.biff; 21 22 import common.Logger; 23 24 27 public class CountryCode 28 { 29 32 private static Logger logger = Logger.getLogger(CountryCode.class); 33 34 37 private int value; 38 39 42 private String code; 43 44 47 private String description; 48 49 52 private static CountryCode[] codes = new CountryCode[0]; 53 54 57 private CountryCode(int v, String c, String d) 58 { 59 value = v; 60 code = c; 61 description = d; 62 63 CountryCode[] newcodes = new CountryCode[codes.length+1]; 64 System.arraycopy(codes, 0, newcodes, 0, codes.length); 65 newcodes[codes.length] = this; 66 codes = newcodes; 67 } 68 69 73 private CountryCode(int v) 74 { 75 value = v; 76 description = "Arbitrary"; 77 code = "??"; 78 } 79 80 85 public int getValue() 86 { 87 return value; 88 } 89 90 95 public String getCode() 96 { 97 return code; 98 } 99 100 103 public static CountryCode getCountryCode(String s) 104 { 105 if (s == null || s.length() != 2) 106 { 107 logger.warn("Please specify two character ISO 3166 country code"); 108 return USA; 109 } 110 111 CountryCode code = UNKNOWN; 112 for (int i = 0 ; i < codes.length && code == UNKNOWN ; i++) 113 { 114 if (codes[i].code.equals(s)) 115 { 116 code = codes[i]; 117 } 118 } 119 120 return code; 121 } 122 123 128 public static CountryCode createArbitraryCode(int i) 129 { 130 return new CountryCode(i); 131 } 132 133 public final static CountryCode USA = new CountryCode(0x1, "US", "USA"); 135 public final static CountryCode CANADA = 136 new CountryCode(0x2, "CA", "Canada"); 137 public final static CountryCode GREECE = 138 new CountryCode(0x1e, "GR", "Greece"); 139 public final static CountryCode NETHERLANDS = 140 new CountryCode(0x1f, "NE", "Netherlands"); 141 public final static CountryCode BELGIUM = 142 new CountryCode(0x20, "BE", "Belgium"); 143 public final static CountryCode FRANCE = 144 new CountryCode(0x21, "FR", "France"); 145 public final static CountryCode SPAIN = new CountryCode(0x22, "ES", "Spain"); 146 public final static CountryCode ITALY = new CountryCode(0x27, "IT", "Italy"); 147 public final static CountryCode SWITZERLAND = 148 new CountryCode(0x29, "CH", "Switzerland"); 149 public final static CountryCode UK = 150 new CountryCode(0x2c, "UK", "United Kingdowm"); 151 public final static CountryCode DENMARK = 152 new CountryCode(0x2d, "DK", "Denmark"); 153 public final static CountryCode SWEDEN = 154 new CountryCode(0x2e, "SE", "Sweden"); 155 public final static CountryCode NORWAY = 156 new CountryCode(0x2f, "NO", "Norway"); 157 public final static CountryCode GERMANY = 158 new CountryCode(0x31, "DE", "Germany"); 159 public final static CountryCode PHILIPPINES = 160 new CountryCode(0x3f, "PH", "Philippines"); 161 public final static CountryCode CHINA = 162 new CountryCode(0x56, "CN", "China"); 163 public final static CountryCode INDIA = 164 new CountryCode(0x5b, "IN", "India"); 165 public final static CountryCode UNKNOWN = 166 new CountryCode(0xffff, "??", "Unknown"); 167 } 168 | Popular Tags |