10c7ca13f3a726e3cf7d7a582c95ab7eea990082aroubert@google.com/* 20c7ca13f3a726e3cf7d7a582c95ab7eea990082aroubert@google.com * Copyright (C) 2010 Google Inc. 30c7ca13f3a726e3cf7d7a582c95ab7eea990082aroubert@google.com * 40c7ca13f3a726e3cf7d7a582c95ab7eea990082aroubert@google.com * Licensed under the Apache License, Version 2.0 (the "License"); 50c7ca13f3a726e3cf7d7a582c95ab7eea990082aroubert@google.com * you may not use this file except in compliance with the License. 60c7ca13f3a726e3cf7d7a582c95ab7eea990082aroubert@google.com * You may obtain a copy of the License at 70c7ca13f3a726e3cf7d7a582c95ab7eea990082aroubert@google.com * 80c7ca13f3a726e3cf7d7a582c95ab7eea990082aroubert@google.com * http://www.apache.org/licenses/LICENSE-2.0 90c7ca13f3a726e3cf7d7a582c95ab7eea990082aroubert@google.com * 100c7ca13f3a726e3cf7d7a582c95ab7eea990082aroubert@google.com * Unless required by applicable law or agreed to in writing, software 110c7ca13f3a726e3cf7d7a582c95ab7eea990082aroubert@google.com * distributed under the License is distributed on an "AS IS" BASIS, 120c7ca13f3a726e3cf7d7a582c95ab7eea990082aroubert@google.com * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 130c7ca13f3a726e3cf7d7a582c95ab7eea990082aroubert@google.com * See the License for the specific language governing permissions and 140c7ca13f3a726e3cf7d7a582c95ab7eea990082aroubert@google.com * limitations under the License. 150c7ca13f3a726e3cf7d7a582c95ab7eea990082aroubert@google.com */ 160c7ca13f3a726e3cf7d7a582c95ab7eea990082aroubert@google.com 170c7ca13f3a726e3cf7d7a582c95ab7eea990082aroubert@google.compackage com.android.i18n.addressinput; 180c7ca13f3a726e3cf7d7a582c95ab7eea990082aroubert@google.com 190c7ca13f3a726e3cf7d7a582c95ab7eea990082aroubert@google.comimport java.util.HashMap; 200c7ca13f3a726e3cf7d7a582c95ab7eea990082aroubert@google.comimport java.util.Map; 210c7ca13f3a726e3cf7d7a582c95ab7eea990082aroubert@google.com 220c7ca13f3a726e3cf7d7a582c95ab7eea990082aroubert@google.com/** 232a2386e14357a672090d07daf6e2316d2dd34b88lararennie@google.com * Enumerates all the data fields found in the JSON-format address property data that are used by 242a2386e14357a672090d07daf6e2316d2dd34b88lararennie@google.com * the Android Address Input Widget. 250c7ca13f3a726e3cf7d7a582c95ab7eea990082aroubert@google.com */ 26dc4cdad9dd71a57be66262d1d6d46a09c0973818lararennie@google.comenum AddressDataKey { 272c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com /** 282c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com * Identifies the countries for which data is provided. 292c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com */ 302c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com COUNTRIES, 312c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com /** 322c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com * The standard format string. This identifies which fields can be used in the address, along 332c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com * with their order. This also carries additional information for use in formatting the fields 342a2386e14357a672090d07daf6e2316d2dd34b88lararennie@google.com * into multiple lines. This is also used to indicate which fields should _not_ be used for an 352a2386e14357a672090d07daf6e2316d2dd34b88lararennie@google.com * address. 362c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com */ 372c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com FMT, 382c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com /** 392a2386e14357a672090d07daf6e2316d2dd34b88lararennie@google.com * The unique ID of the region, in the form of a path from parent IDs to the key. 402c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com */ 412c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com ID, 422c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com /** 432a2386e14357a672090d07daf6e2316d2dd34b88lararennie@google.com * The key of the region, unique to its parent. If there is an accepted abbreviation for this 442a2386e14357a672090d07daf6e2316d2dd34b88lararennie@google.com * region, then the key will be set to this and name will be set to the local name for this 452a2386e14357a672090d07daf6e2316d2dd34b88lararennie@google.com * region. If there is no accepted abbreviation, then this key will be the local name and there 462a2386e14357a672090d07daf6e2316d2dd34b88lararennie@google.com * will be no local name specified. This value must be present. 472c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com */ 482c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com KEY, 492c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com /** 502a2386e14357a672090d07daf6e2316d2dd34b88lararennie@google.com * The language of this data, if known. 512c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com */ 522c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com LANG, 532c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com /** 542c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com * The latin format string {@link #FMT} used when a country defines an alternative format for 552a2386e14357a672090d07daf6e2316d2dd34b88lararennie@google.com * use with the latin script, such as in China. 562c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com */ 572c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com LFMT, 582c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com /** 59771cc560df04dc201a90012c15b5814c33f6d5d8lararennie@google.com * Indicates the type of the name used for the locality (city) field. 60771cc560df04dc201a90012c15b5814c33f6d5d8lararennie@google.com */ 61771cc560df04dc201a90012c15b5814c33f6d5d8lararennie@google.com LOCALITY_NAME_TYPE, 62771cc560df04dc201a90012c15b5814c33f6d5d8lararennie@google.com /** 632c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com * Indicates which fields must be present in a valid address. 642c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com */ 652c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com REQUIRE, 662c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com /** 67771cc560df04dc201a90012c15b5814c33f6d5d8lararennie@google.com * Indicates the type of the name used for the state (administrative area) field. 682c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com */ 692c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com STATE_NAME_TYPE, 702c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com /** 712a2386e14357a672090d07daf6e2316d2dd34b88lararennie@google.com * Encodes the {@link #KEY} value of all the children of this region. 722c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com */ 732c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com SUB_KEYS, 742c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com /** 752a2386e14357a672090d07daf6e2316d2dd34b88lararennie@google.com * Encodes the transliterated latin name value of all the children of this region, if the local 762a2386e14357a672090d07daf6e2316d2dd34b88lararennie@google.com * names are not in latin script already. 772c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com */ 782c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com SUB_LNAMES, 792c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com /** 802a2386e14357a672090d07daf6e2316d2dd34b88lararennie@google.com * Indicates, for each child of this region, whether that child has additional children. 812c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com */ 822c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com SUB_MORES, 832c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com /** 842a2386e14357a672090d07daf6e2316d2dd34b88lararennie@google.com * Encodes the local name value of all the children of this region. 852c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com */ 862c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com SUB_NAMES, 872c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com /** 882c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com * Encodes the {@link #ZIP} value for the subtree beneath this region. 892c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com */ 902c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com XZIP, 912c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com /** 922c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com * Encodes the postal code pattern if at the country level, and the postal code prefix if at a 932c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com * level below country. 942c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com */ 952c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com ZIP, 962c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com /** 97771cc560df04dc201a90012c15b5814c33f6d5d8lararennie@google.com * Indicates the type of the name used for the ZIP (postal code) field. 982c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com */ 992c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com ZIP_NAME_TYPE; 1000c7ca13f3a726e3cf7d7a582c95ab7eea990082aroubert@google.com 1012c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com /** 1022c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com * Returns a field based on its keyname (value in the JSON-format file), or null if no field 1032c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com * matches. 1042c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com */ 105dc4cdad9dd71a57be66262d1d6d46a09c0973818lararennie@google.com static AddressDataKey get(String keyname) { 106e9664fb4251726db44bec0751f77026e23ce71bbshaopengjia@google.com return ADDRESS_KEY_NAME_MAP.get(keyname.toLowerCase()); 1072c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com } 1082c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com 109e9664fb4251726db44bec0751f77026e23ce71bbshaopengjia@google.com private static final Map<String, AddressDataKey> ADDRESS_KEY_NAME_MAP = 110e9664fb4251726db44bec0751f77026e23ce71bbshaopengjia@google.com new HashMap<String, AddressDataKey>(); 1110c7ca13f3a726e3cf7d7a582c95ab7eea990082aroubert@google.com 1122c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com static { 1132a2386e14357a672090d07daf6e2316d2dd34b88lararennie@google.com // Populates the map of enums against their lower-cased string values for easy look-up. 1142a2386e14357a672090d07daf6e2316d2dd34b88lararennie@google.com for (AddressDataKey field : values()) { 115e9664fb4251726db44bec0751f77026e23ce71bbshaopengjia@google.com ADDRESS_KEY_NAME_MAP.put(field.toString().toLowerCase(), field); 1162c25a6f4922225b619b0e389befde8b941e78834jeanine@google.com } 1170c7ca13f3a726e3cf7d7a582c95ab7eea990082aroubert@google.com } 1180c7ca13f3a726e3cf7d7a582c95ab7eea990082aroubert@google.com} 119