Home | History | Annotate | Download | only in addressinput
      1 /*
      2  * Copyright (C) 2010 Google Inc.
      3  *
      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
      7  *
      8  * http://www.apache.org/licenses/LICENSE-2.0
      9  *
     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.
     15  */
     16 
     17 package com.android.i18n.addressinput;
     18 
     19 import java.util.Iterator;
     20 import java.util.Map;
     21 
     22 /**
     23  * A map of {@link AddressDataKey}s to JSON strings. Provides data for a single node in the address
     24  * data hierarchy (for example, "data/US/CA"). Key is an AddressDataKey and the value is the raw
     25  * string representing that data. This is either a single string, or an array of strings represented
     26  * as a single string using '~' to separate the elements of the array, depending on the
     27  * AddressDataKey.
     28  */
     29 public class AddressVerificationNodeData {
     30 
     31     private final Map<AddressDataKey, String> mMap;
     32 
     33     public AddressVerificationNodeData(Map<AddressDataKey, String> map) {
     34         Util.checkNotNull("Cannot construct StandardNodeData with null map");
     35         mMap = map;
     36     }
     37 
     38     /**
     39      * Iterates through the map.
     40      */
     41     public Iterator<AddressDataKey> iterator() {
     42         return mMap.keySet().iterator();
     43     }
     44 
     45     public boolean containsKey(AddressDataKey key) {
     46         return mMap.containsKey(key);
     47     }
     48 
     49     /**
     50      * Gets the value for a particular key in the map.
     51      */
     52     public String get(AddressDataKey key) {
     53         return mMap.get(key);
     54     }
     55 }
     56