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 which fields must be present in a valid address.
63 * Indicates the name used for the admin areas for a particular region.
67 * Encodes the {@link #KEY} value of all the children of this region.
71 * Encodes the transliterated latin name value of all the children of this region, if the local
72 * names are not in latin script already.
76 * Indicates, for each child of this region, whether that child has additional children.
80 * Encodes the local name value of all the children of this region.
84 * Encodes the {@link #ZIP} value for the subtree beneath this region.
88 * Encodes the postal code pattern if at the country level, and the postal code prefix if at a
89 * level below country.
93 * Indicates the name used for the postal code for a particular region.
98 * Returns a field based on its keyname (value in the JSON-format file), or null if no field
101 static AddressDataKey get(String keyname) {
102 return ADDRESS_KEY_NAME_MAP.get(keyname.toLowerCase());
105 private static final Map<String, AddressDataKey> ADDRESS_KEY_NAME_MAP =
106 new HashMap<String, AddressDataKey>();
109 // Populates the map of enums against their lower-cased string values for easy look-up.
110 for (AddressDataKey field : values()) {
111 ADDRESS_KEY_NAME_MAP.put(field.toString().toLowerCase(), field);