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.Arrays;
20 import java.util.Collections;
21 import java.util.HashMap;
22 import java.util.List;
26 * Loader for a map defining the standard checks to perform on AddressFields.
28 public class StandardChecks {
30 private StandardChecks() {
33 public static final Map<AddressField, List<AddressProblemType>> PROBLEM_MAP;
36 Map<AddressField, List<AddressProblemType>> map =
37 new HashMap<AddressField, List<AddressProblemType>>();
39 addToMap(map, AddressField.COUNTRY, AddressProblemType.USING_UNUSED_FIELD,
40 AddressProblemType.MISSING_REQUIRED_FIELD, AddressProblemType.UNKNOWN_VALUE);
41 addToMap(map, AddressField.ADMIN_AREA, AddressProblemType.USING_UNUSED_FIELD,
42 AddressProblemType.MISSING_REQUIRED_FIELD, AddressProblemType.UNKNOWN_VALUE);
43 addToMap(map, AddressField.LOCALITY, AddressProblemType.USING_UNUSED_FIELD,
44 AddressProblemType.MISSING_REQUIRED_FIELD, AddressProblemType.UNKNOWN_VALUE);
45 addToMap(map, AddressField.DEPENDENT_LOCALITY, AddressProblemType.USING_UNUSED_FIELD,
46 AddressProblemType.MISSING_REQUIRED_FIELD, AddressProblemType.UNKNOWN_VALUE);
47 addToMap(map, AddressField.POSTAL_CODE, AddressProblemType.USING_UNUSED_FIELD,
48 AddressProblemType.MISSING_REQUIRED_FIELD, AddressProblemType.UNRECOGNIZED_FORMAT,
49 AddressProblemType.MISMATCHING_VALUE);
50 addToMap(map, AddressField.STREET_ADDRESS, AddressProblemType.USING_UNUSED_FIELD,
51 AddressProblemType.MISSING_REQUIRED_FIELD);
52 addToMap(map, AddressField.SORTING_CODE, AddressProblemType.USING_UNUSED_FIELD,
53 AddressProblemType.MISSING_REQUIRED_FIELD);
54 addToMap(map, AddressField.ORGANIZATION, AddressProblemType.USING_UNUSED_FIELD,
55 AddressProblemType.MISSING_REQUIRED_FIELD);
56 addToMap(map, AddressField.RECIPIENT, AddressProblemType.USING_UNUSED_FIELD,
57 AddressProblemType.MISSING_REQUIRED_FIELD);
59 PROBLEM_MAP = Collections.unmodifiableMap(map);
62 private static void addToMap(Map<AddressField, List<AddressProblemType>> map,
64 AddressProblemType... problems) {
65 map.put(field, Collections.unmodifiableList(Arrays.asList(problems)));