2 * Copyright (C) 2010 Google Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.i18n.addressinput;
19 import java.util.HashMap;
23 * Enumerates all the data fields found in the JSON-format address property data that are used by
24 * the Android Address Input Widget.
28 * Identifies the countries for which data is provided.
32 * The standard format string. This identifies which fields can be used in the address, along
33 * with their order. This also carries additional information for use in formatting the fields
34 * into multiple lines. This is also used to indicate which fields should _not_ be used for an
39 * The unique ID of the region, in the form of a path from parent IDs to the key.
43 * The key of the region, unique to its parent. If there is an accepted abbreviation for this
44 * region, then the key will be set to this and name will be set to the local name for this
45 * region. If there is no accepted abbreviation, then this key will be the local name and there
46 * will be no local name specified. This value must be present.
50 * The language of this data, if known.
54 * The latin format string {@link #FMT} used when a country defines an alternative format for
55 * use with the latin script, such as in China.
59 * Indicates the type of the name used for the locality (city) field.
63 * Indicates which fields must be present in a valid address.
67 * Indicates the type of the name used for the state (administrative area) field.
71 * Encodes the {@link #KEY} value of all the children of this region.
75 * Encodes the transliterated latin name value of all the children of this region, if the local
76 * names are not in latin script already.
80 * Indicates the type of the name used for the sublocality field.
82 SUBLOCALITY_NAME_TYPE,
84 * Indicates, for each child of this region, whether that child has additional children.
88 * Encodes the local name value of all the children of this region.
92 * Encodes the {@link #ZIP} value for the subtree beneath this region.
96 * Encodes the postal code pattern if at the country level, and the postal code prefix if at a
97 * level below country.
101 * Indicates the type of the name used for the ZIP (postal code) field.
106 * Returns a field based on its keyname (value in the JSON-format file), or null if no field
109 static AddressDataKey get(String keyname) {
110 return ADDRESS_KEY_NAME_MAP.get(keyname.toLowerCase());
113 private static final Map<String, AddressDataKey> ADDRESS_KEY_NAME_MAP =
114 new HashMap<String, AddressDataKey>();
117 // Populates the map of enums against their lower-cased string values for easy look-up.
118 for (AddressDataKey field : values()) {
119 ADDRESS_KEY_NAME_MAP.put(field.toString().toLowerCase(), field);