[Android]中国大部分城市地区的结构定义与按拼音排序

项目中涉及到送货地址,录入工作量挺耗时的,分享出来,减免大家的重复劳动。

先见效果图如下:

          





本示例中使用Hashtable记录了中国大部分城市与地区的数据。其结构如下:

Hashtable(Head)
    ↑
↑←←←←←←←←←←←←(key,Hashtable<key,String[]>)
    ↑
↑←←←←←←←←←←←←("福建省",Hashtable<"福州市",{"仓山区"、"晋安区"... ...}>)
 
这个数据结构封装在了ChinaCityUtil工具类中。该类中定义了三种行政区类型,分别为:
TYPE_PROVINCE  省、直辖市、自治区级别
TYPE_CITY  城市
TYPE_REGION  城区

TYPE_PROVINCE级别的名称都是Hashtable(Head)的Key值集合,TYPE_CITY级别的名称是子Hashtable的Key值集合,TYPE_REGION级别的名称则直接就是String数组了。则很明确,为了获取Hashtable中Key值的集合,此处实现了一个方法getKeyArrayByTable(Hashtable<String, ? extends Object>)。

ChinaCityUtil中实现的另一个重要方法为findAreaStringArr(Hashtable<String, Hashtable<String, String[]>> table,
int type, String... args),该方法的最后一个参数args为指定想要获取的地区。如想获取"福建省"或"福建省"下"福州市"的所有区级别地区名称,则执行:

[java] view plaincopy
  1. String[] arrCity = findAreaStringArr(hashtableHead,TYPE_REGION,"福建省");  
  2. String[] arrRegion = findAreaStringArr(hashtableHead,TYPE_REGION,"福建省","福州市");  



由于Hashtable取key值时是无序的,为了方便用户选择地区,还需要对取得的数组进行按拼音排序。Java中,Collator可实现此功能。Collator在Comparator实例化后,通过ArrayAdapter.sort(comparator)与显示地区数组的适配器结合起来进行排序。

在开发过程中,会发现“重庆市”竟然排在了最后,究其原因为“重”在程序中被以拼音“zhong”的第四音进行排序了。为让以"chong"第二音进行排序,则在Comparator.compare(Strin obj1,String obj2)方法中在其进行比较顺序之前执行如下代码:

[java] view plaincopy
  1. String  obj1 = obj1.replace("重庆""崇庆");  
  2. String  obj2 = obj2.replace("重庆""崇庆");  

以同样为"chong"第四音的"崇"字进行排序即可。

完整代码如下:


ChinaCityAct.java

[java] view plaincopy
  1. package lab.sodino.chinacity;  
  2.   
  3. import java.util.Hashtable;  
  4.   
  5. import android.app.Activity;  
  6. import android.os.Bundle;  
  7. import android.view.View;  
  8. import android.widget.AdapterView;  
  9. import android.widget.ArrayAdapter;  
  10. import android.widget.Spinner;  
  11. import android.widget.TextView;  
  12.   
  13. /** 
  14.  * @author Sodino E-mail:sodinoopen@hotmail.com 
  15.  * @version Time:2011-8-20 下午08:41:25 
  16.  */  
  17. public class ChinaCityAct extends Activity implements AdapterView.OnItemSelectedListener {  
  18.     private ChinaAlphabetComparator comparator;  
  19.     private Spinner spinnerProvince;  
  20.     private Spinner spinnerCity;  
  21.     private Spinner spinnerRegion;  
  22.     private TextView txtInfo;  
  23.     private Hashtable<String, Hashtable<String, String[]>> hashtable;  
  24.     private String[] arrProvince, arrCity, arrRegion;  
  25.     private String province, city, region;  
  26.   
  27.     /** Called when the activity is first created. */  
  28.     @Override  
  29.     public void onCreate(Bundle savedInstanceState) {  
  30.         super.onCreate(savedInstanceState);  
  31.         setContentView(R.layout.main);  
  32.         comparator = new ChinaAlphabetComparator();  
  33.         hashtable = ChinaCityUtil.initChinaCitysHashtable();  
  34.         arrProvince = ChinaCityUtil.findAreaStringArr(hashtable, ChinaCityUtil.TYPE_PROVINCE);  
  35.         ArrayAdapter<String> adapterProvince = getArrayAdapter(arrProvince);  
  36.         spinnerProvince = (Spinner) findViewById(R.id.spinnerProvince);  
  37.         spinnerProvince.setAdapter(adapterProvince);  
  38.         spinnerProvince.setOnItemSelectedListener(this);  
  39.         spinnerCity = (Spinner) findViewById(R.id.spinnerCity);  
  40.         spinnerCity.setOnItemSelectedListener(this);  
  41.         spinnerRegion = (Spinner) findViewById(R.id.spinnerRegion);  
  42.         spinnerRegion.setOnItemSelectedListener(this);  
  43.         txtInfo = (TextView) findViewById(R.id.txtInfo);  
  44.     }  
  45.   
  46.     private ArrayAdapter<String> getArrayAdapter(String[] arr) {  
  47.         ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,  
  48.                 android.R.layout.simple_spinner_item, arr);  
  49.         adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);  
  50.         adapter.sort(comparator);  
  51.         return adapter;  
  52.     }  
  53.   
  54.     private void modifyCity(String province) {  
  55.         arrCity = ChinaCityUtil.findAreaStringArr(hashtable, ChinaCityUtil.TYPE_CITY, province);  
  56.         ArrayAdapter<String> adapterCity = getArrayAdapter(arrCity);  
  57.         spinnerCity.setAdapter(adapterCity);  
  58.     }  
  59.   
  60.     private void modifyRegion(String province, String city) {  
  61.         arrRegion = ChinaCityUtil.findAreaStringArr(hashtable, ChinaCityUtil.TYPE_REGION, province,  
  62.                 city);  
  63.         ArrayAdapter<String> adapterRegion = getArrayAdapter(arrRegion);  
  64.         spinnerRegion.setAdapter(adapterRegion);  
  65.     }  
  66.   
  67.     @Override  
  68.     public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {  
  69.         if (parent == spinnerProvince) {  
  70.             province = arrProvince[position];  
  71.             modifyCity(province);  
  72.         } else if (parent == spinnerCity) {  
  73.             city = arrCity[position];  
  74.             modifyRegion(province, city);  
  75.         } else if (parent == spinnerRegion) {  
  76.             region = arrRegion[position];  
  77.             txtInfo.setText(province + " " + city + " " + region);  
  78.         }  
  79.     }  
  80.   
  81.     @Override  
  82.     public void onNothingSelected(AdapterView<?> parent) {  
  83.   
  84.     }  
  85. }  


ChinaAlphabetComparator.java

[java] view plaincopy
  1. package lab.sodino.chinacity;  
  2.   
  3. import java.text.CollationKey;  
  4. import java.text.Collator;  
  5. import java.text.RuleBasedCollator;  
  6. import java.util.Comparator;  
  7.   
  8. /** 
  9.  * @author Sodino E-mail:sodinoopen@hotmail.com 
  10.  * @version Time:2011-8-20 下午08:41:25 
  11.  */  
  12. public class ChinaAlphabetComparator implements Comparator<String> {  
  13.   
  14.     private RuleBasedCollator collator;  
  15.   
  16.     public ChinaAlphabetComparator() {  
  17.         collator = (RuleBasedCollator) Collator.getInstance(java.util.Locale.CHINA);  
  18.     }  
  19.   
  20.     @Override  
  21.     public int compare(String obj1, String obj2) {  
  22.         obj1 = obj1.replace("重庆""崇庆");  
  23.         obj2 = obj2.replace("重庆""崇庆");  
  24.         CollationKey c1 = collator.getCollationKey(obj1);  
  25.         CollationKey c2 = collator.getCollationKey(obj2);  
  26.         // When sorting a list of Strings however, it is generally necessary to  
  27.         // compare each String multiple times. In this case, CollationKeys  
  28.         // provide better performance. The CollationKey class converts a String  
  29.         // to a series of bits that can be compared bitwise against other  
  30.         // CollationKeys. A CollationKey is created by a Collator object for a  
  31.         // given String.  
  32.         return c1.compareTo(c2);  
  33.         // return collator.compare(c1.getSourceString(), c2.getSourceString());  
  34.     }  
  35. }  

ChinaCityUtil.java

[java] view plaincopy
  1. package lab.sodino.chinacity;  
  2.   
  3. import java.util.ArrayList;  
  4. import java.util.Hashtable;  
  5. import java.util.Iterator;  
  6. import java.util.List;  
  7. import java.util.Set;  
  8.   
  9. /** 
  10.  * @author Sodino E-mail:sodinoopen@hotmail.com 
  11.  * @version Time:2011-8-20 下午08:41:25 
  12.  */  
  13. public class ChinaCityUtil {  
  14.     public static final String CHINA = "中国";  
  15.     public static final int TYPE_PROVINCE = 1;  
  16.     public static final int TYPE_CITY = 2;  
  17.     public static final int TYPE_REGION = 3;  
  18.   
  19.     public static Hashtable<String, Hashtable<String, String[]>> initChinaCitysHashtable() {  
  20.         Hashtable<String, Hashtable<String, String[]>> tmpProvince = new Hashtable<String, Hashtable<String, String[]>>();  
  21.         // 从小地区开始构建  
  22.         Hashtable<String, String[]> tmpCity = null;  
  23.         // 北京市  
  24.         tmpCity = new Hashtable<String, String[]>();  
  25.         tmpCity.put("北京市"new String[] { "昌平区""朝阳区""崇文区""大兴区""东城区""房山区""丰台区""海淀区",  
  26.                 "怀柔区""门头沟""密云区""平谷区""石景山区""顺义区""通州区""西城区""宣武区""延庆县" });  
  27.         tmpProvince.put("北京市", tmpCity);  
  28.         // 安徽省  
  29.         tmpCity = new Hashtable<String, String[]>();  
  30.         tmpCity.put("安庆市"new String[] { "大观区""宜秀区""迎江区" });  
  31.         tmpCity.put("蚌埠市"new String[] { "蚌山区""龙子湖区""禹会区" });  
  32.         tmpCity.put("亳州市"new String[] { "谯城区" });  
  33.         tmpCity.put("巢湖市"new String[] { "居巢区" });  
  34.         tmpCity.put("滁州市"new String[] { "琅琊区""南谯区" });  
  35.         tmpCity.put("阜阳市"new String[] { "太和县""颖东区""颖泉区""颖州区" });  
  36.         tmpCity.put("合肥市"new String[] { "包河区""庐阳区""蜀山区""瑶海区" });  
  37.         tmpCity.put("淮北市"new String[] { "杜集区""相山区" });  
  38.         tmpCity.put("淮南市"new String[] { "大通区""田家庵区" });  
  39.         tmpCity.put("黄山市"new String[] { "屯溪区""休宁县" });  
  40.         tmpCity.put("六安市"new String[] { "金安区""裕安区" });  
  41.         tmpCity.put("马鞍山市"new String[] { "花山区""金家庄区""雨山区" });  
  42.         tmpCity.put("宿州市"new String[] { "埇桥区" });  
  43.         tmpCity.put("铜陵市"new String[] { "铜官山区 狮子山区" });  
  44.         tmpCity.put("芜湖市"new String[] { "镜湖区""鸠江区""南陵县""芜湖县""弋江区" });  
  45.         tmpCity.put("宣城市"new String[] { "泾县""宣州区" });  
  46.         tmpCity.put("池州市"new String[] { "贵池区" });  
  47.         tmpProvince.put("安徽省", tmpCity);  
  48.         // 重庆市  
  49.         tmpCity = new Hashtable<String, String[]>();  
  50.         tmpCity.put("重庆市"new String[] { "巴南区""北碚区""璧山县""长寿县""大渡口区""大足县""垫江县""涪陵区",  
  51.                 "合川区""江北区""江津区""九龙坡区""南岸区""南川区""綦江县""黔江区""荣昌县""沙坪坝区""铜梁县",  
  52.                 "万州区""永川区""渝北区""渝中区""云阳县""忠县" });  
  53.         tmpProvince.put("重庆市", tmpCity);  
  54.         // 福建省  
  55.         tmpCity = new Hashtable<String, String[]>();  
  56.         tmpCity.put("福州市"new String[] { "仓山区""长乐市""福清市""鼓楼区""晋安区""连江县""马尾区""闽侯县",  
  57.                 "台江区" });  
  58.         tmpCity.put("龙岩市"new String[] { "新罗区" });  
  59.         tmpCity.put("南平市"new String[] { "光泽县""建瓯市""建阳市""邵武市""顺昌县""松溪县""武夷山市""延平区",  
  60.                 "政和县" });  
  61.         tmpCity.put("宁德市"new String[] { "福安市""福鼎市""蕉城区""屏南县""寿宁县""柘荣县""周宁县" });  
  62.         tmpCity.put("莆田市"new String[] { "城厢区""涵江区""荔城区" });  
  63.         tmpCity.put("泉州市"new String[] { "安溪县""德化县""丰泽区""惠安县""晋江市""鲤城区""洛江区""南安市",  
  64.                 "石狮市""永春县" });  
  65.         tmpCity.put("三明市"new String[] { "梅列区""三元区" });  
  66.         tmpCity.put("厦门市"new String[] { "海沧区""湖里区""集美区""思明区""同安区""翔安区" });  
  67.         tmpCity.put("漳州市"new String[] { "龙文区""芗城区" });  
  68.         tmpProvince.put("福建省", tmpCity);  
  69.         // 甘肃省  
  70.         tmpCity = new Hashtable<String, String[]>();  
  71.         tmpCity.put("白银市"new String[] { "白银区" });  
  72.         tmpCity.put("嘉峪关市"new String[] {});  
  73.         tmpCity.put("酒泉市"new String[] { "敦煌市肃州区" });  
  74.         tmpCity.put("兰州市"new String[] { "安宁区""城关区""七里河区""西固区" });  
  75.         tmpCity.put("平凉市"new String[] { "崆峒区" });  
  76.         tmpCity.put("庆阳市"new String[] { "庆城县""西峰区" });  
  77.         tmpCity.put("天水市"new String[] { "麦积区""秦州区" });  
  78.         tmpCity.put("武威市"new String[] { "凉州区" });  
  79.         tmpCity.put("张掖市"new String[] { "甘州区" });  
  80.         tmpCity.put("定西市"new String[] { "安定区" });  
  81.         tmpCity.put("陇南市"new String[] { "武都区" });  
  82.         tmpProvince.put("甘肃省", tmpCity);  
  83.         // 广东省  
  84.         tmpCity = new Hashtable<String, String[]>();  
  85.         tmpCity.put("东莞市"new String[] { "东莞市" });  
  86.         tmpCity.put("佛山市"new String[] { "禅城区""高明区""南海区""顺德区三水区" });  
  87.         tmpCity.put("广州市"new String[] { "白云区""从化市""番禺区""海珠区""花都区""黄浦区""南沙区""萝岗区",  
  88.                 "荔湾区""天河区""越秀区""增城市" });  
  89.         tmpCity.put("河源市"new String[] { "东源县""龙川县""源城区" });  
  90.         tmpCity.put("惠州市"new String[] { "博罗县""惠城区""惠东县""惠阳区" });  
  91.         tmpCity.put("江门市"new String[] { "江海区""蓬江区""新会区" });  
  92.         tmpCity.put("茂名市"new String[] { "茂港区""茂南区" });  
  93.         tmpCity.put("梅州市"new String[] { "梅州市市区" });  
  94.         tmpCity.put("清远市"new String[] { "连州市""清新县""英德市清城区" });  
  95.         tmpCity.put("汕头市"new String[] { "潮南区""潮阳区""澄海区""全平区""龙湖区" });  
  96.         tmpCity.put("汕尾市"new String[] { "城区""海丰区""陆丰区""陆河县" });  
  97.         tmpCity.put("韶关市"new String[] { "浈江区""乐昌市""南雄市""仁化县""乳源瑶族自治县""始兴县""武江区",  
  98.                 "浈江区曲江区 " });  
  99.         tmpCity.put("深圳市"new String[] { "宝安区""福田区""龙岗区""罗湖区""南山区""盐田区" });  
  100.         tmpCity.put("阳江市"new String[] { "江城区""阳春市""阳东县""阳西县" });  
  101.         tmpCity.put("云浮市"new String[] { "云城区" });  
  102.         tmpCity.put("湛江市"new String[] { "赤坎区""麻章区""坡头区""霞山区" });  
  103.         tmpCity.put("肇庆市"new String[] { "鼎湖区""端州区" });  
  104.         tmpCity.put("中山市"new String[] { "中山市" });  
  105.         tmpCity.put("珠海市"new String[] { "斗门区""金湾区""香洲区" });  
  106.         tmpProvince.put("广东省", tmpCity);  
  107.         // 广西壮族自治区  
  108.         tmpCity = new Hashtable<String, String[]>();  
  109.         tmpCity.put("百色市"new String[] { "凌云县""平果县""田东县""田阳县""右江区""靖西县" });  
  110.         tmpCity.put("北海市"new String[] { "海城区""合浦县""银海区" });  
  111.         tmpCity.put("崇左市"new String[] { "江洲区""龙州县""宁明县""凭祥市" });  
  112.         tmpCity.put("防城港市"new String[] { "防城区""港口区" });  
  113.         tmpCity.put("贵港市"new String[] { "港北区""港南区""覃塘区""桂平市" });  
  114.         tmpCity.put("桂林市"new String[] { "叠彩区""七星区""象山区""秀峰区""雁山区" });  
  115.         tmpCity.put("河池市"new String[] { "金城江区""宜州区" });  
  116.         tmpCity.put("贺州市"new String[] { "八步区钟山县" });  
  117.         tmpCity.put("来宾市"new String[] { "兴宾区""忻城县" });  
  118.         tmpCity.put("柳州市"new String[] { "城中区""柳北区""柳南区""鱼峰区柳江县 融安县" });  
  119.         tmpCity.put("南宁市"new String[] { "西乡塘区""江南区""青秀区""兴宁区""良庆区 武鸣县""横县""宾阳县" });  
  120.         tmpCity.put("钦州市"new String[] { "钦北区""钦南区" });  
  121.         tmpCity.put("梧州市"new String[] { "苍梧县""长洲区""蝶山区""万秀区""岑溪市" });  
  122.         tmpCity.put("玉林市"new String[] { "玉州区""兴业县""博白县" });  
  123.         tmpProvince.put("广西壮族自治区", tmpCity);  
  124.         // 贵州省  
  125.         tmpCity = new Hashtable<String, String[]>();  
  126.         tmpCity.put("安顺市"new String[] { "西秀区" });  
  127.         tmpCity.put("毕节市"new String[] { "毕节地区" });  
  128.         tmpCity.put("贵阳市"new String[] { "白云区""花溪区""南明区""乌当区""小河区""云岩区" });  
  129.         tmpCity.put("六盘水市"new String[] { "水城县""中山区" });  
  130.         tmpCity.put("黔东南苗族侗族自治州"new String[] { "凯里市" });  
  131.         tmpCity.put("黔南布依族苗族自治州"new String[] { "都匀市" });  
  132.         tmpCity.put("黔西南布依族苗族自治州"new String[] { "兴义市" });  
  133.         tmpCity.put("铜仁市"new String[] { "铜仁地区" });  
  134.         tmpCity.put("遵义市"new String[] { "红花岗区""汇川区""仁怀市" });  
  135.         tmpProvince.put("贵州省", tmpCity);  
  136.         // 海南省  
  137.         tmpCity = new Hashtable<String, String[]>();  
  138.         tmpCity.put("海口市"new String[] { "龙华区""美兰区""琼山区""秀英区" });  
  139.         tmpCity.put("三亚市"new String[] { "三亚市" });  
  140.         tmpProvince.put("海南省", tmpCity);  
  141.         // 河北省  
  142.         tmpCity = new Hashtable<String, String[]>();  
  143.         tmpCity.put("保定市"new String[] { "北市区""定兴县""定州市""高碑店市""南市区""清苑县""新市区""涿州市" });  
  144.         tmpCity.put("沧州市"new String[] { "沧县""黄骅市""青县""新华区""运河区" });  
  145.         tmpCity.put("承德市"new String[] { "双桥区""鹰手营子矿区""承德市" });  
  146.         tmpCity.put("邯郸市"new String[] { "丛台区""复兴区""邯郸县""邯山区" });  
  147.         tmpCity.put("衡水市"new String[] { "桃城区" });  
  148.         tmpCity.put("廊坊市"new String[] { "安次区""霸州市""固安市""广阳区""三河市""香河县" });  
  149.         tmpCity.put("秦皇岛市"new String[] { "北戴河区""昌黎县""抚宁县""海港区" });  
  150.         tmpCity.put("石家庄市"new String[] { "长安区""藁城市""鹿泉市""桥东市""桥西区""新华区""裕华区""正定县" });  
  151.         tmpCity.put("唐山市"new String[] { "丰南区""丰润区""古治区""开平区""路北区""路南区""滦县""唐海县" });  
  152.         tmpCity.put("邢台市"new String[] { "桥东区""桥西区" });  
  153.         tmpCity.put("张家口市"new String[] { "桥东区""桥西区""下花园区""宣化区""宣化县" });  
  154.         tmpProvince.put("河北省", tmpCity);  
  155.         // 河南省  
  156.         tmpCity = new Hashtable<String, String[]>();  
  157.         tmpCity.put("安阳市"new String[] { "北关区""龙安区""文峰区""殷都区" });  
  158.         tmpCity.put("河南省直辖"new String[] { "济源市" });  
  159.         tmpCity.put("鹤壁市"new String[] { "鹤山区""淇滨区""山城区" });  
  160.         tmpCity.put("焦作市"new String[] { "解放区""马村区""孟州区""山阳区""中站区" });  
  161.         tmpCity.put("开封市"new String[] { "鼓楼区""金明区""龙亭区""顺河回族区""禹王台区" });  
  162.         tmpCity.put("洛阳市"new String[] { "瀍河回族区""吉利区""涧西区""老城区""洛龙区""西工区" });  
  163.         tmpCity.put("漯河市"new String[] { "郾城区""源汇区""召陵区" });  
  164.         tmpCity.put("南阳市"new String[] { "邓州市""宛城区""卧龙区" });  
  165.         tmpCity.put("平顶山市"new String[] { "卫东区""新华区""湛河区" });  
  166.         tmpCity.put("濮阳市"new String[] { "华龙区" });  
  167.         tmpCity.put("三门峡市"new String[] { "三门峡市" });  
  168.         tmpCity.put("商丘市"new String[] { "梁园区""睢阳区""永城市" });  
  169.         tmpCity.put("新乡市"new String[] { "红旗区""辉县市""牧野区""卫滨区""卫辉市" });  
  170.         tmpCity.put("信阳市"new String[] { "固始县""平桥区""浉河区" });  
  171.         tmpCity.put("许昌市"new String[] { "长葛市""魏都区""许昌县" });  
  172.         tmpCity.put("郑州市"new String[] { "二七区""管城回族区""金水区""中原区""惠济区" });  
  173.         tmpCity.put("周口市"new String[] { "川汇区" });  
  174.         tmpCity.put("驻马店市"new String[] { "驿城区" });  
  175.         tmpProvince.put("河南省", tmpCity);  
  176.         // 黑龙江省  
  177.         tmpCity = new Hashtable<String, String[]>();  
  178.         tmpCity.put("大庆市"new String[] { "龙凤区""让胡路区""萨尔图区" });  
  179.         tmpCity.put("哈尔滨市"new String[] { "道里区""道外区""南岗区""平房区""香坊区""松北区" });  
  180.         tmpCity.put("黑河市"new String[] { "爱辉区" });  
  181.         tmpCity.put("鸡西市"new String[] { "鸡冠区" });  
  182.         tmpCity.put("佳木斯市"new String[] { "东风区""郊区""前进区""向阳区s" });  
  183.         tmpCity.put("牡丹江市"new String[] { "爱民区""东安区""西安区""阳明区" });  
  184.         tmpCity.put("齐齐哈尔市"new String[] { "建华区""龙沙区""梅里斯达斡尔族区""铁锋区" });  
  185.         tmpCity.put("双鸭山市"new String[] { "宝山区""岭东区""四方台区""尖山区" });  
  186.         tmpCity.put("绥化市"new String[] { "北林区" });  
  187.         tmpCity.put("伊春市"new String[] { "伊春区" });  
  188.         tmpCity.put("满洲里"new String[] {});  
  189.         tmpCity.put("鹤岗市"new String[] { "工农区""南山区""向阳区" });  
  190.         tmpCity.put("七台河市"new String[] { "桃山区" });  
  191.         tmpProvince.put("黑龙江省", tmpCity);  
  192.         // 湖北省  
  193.         tmpCity = new Hashtable<String, String[]>();  
  194.         tmpCity.put("鄂州市"new String[] { "鄂城区""华容区""梁子湖区" });  
  195.         tmpCity.put("恩施土家族苗族自治州"new String[] { "恩施市" });  
  196.         tmpCity.put("黄冈市"new String[] { "黄州区" });  
  197.         tmpCity.put("黄石市"new String[] { "黄石港区""铁山区""下陆区 西塞山区" });  
  198.         tmpCity.put("荆门市"new String[] { "东宝区""掇刀区" });  
  199.         tmpCity.put("荆州市"new String[] { "洪湖市""荆州区""沙市区""石首市""松滋市" });  
  200.         tmpCity.put("十堰市"new String[] { "茅箭区""张湾区" });  
  201.         tmpCity.put("随州市"new String[] { "曾都区" });  
  202.         tmpCity.put("天门市"new String[] {});  
  203.         tmpCity.put("武汉市"new String[] { "东西湖区""汉阳区""洪山区""江岸区""江汉区""江夏区""硚口区""青山区",  
  204.                 "武昌区""新洲区" });  
  205.         tmpCity.put("咸宁市"new String[] { "咸安区" });  
  206.         tmpCity.put("襄樊市"new String[] { "樊城区""襄城区""襄阳区""二气开发区" });  
  207.         tmpCity.put("孝感市"new String[] { "孝南区" });  
  208.         tmpCity.put("宜昌市"new String[] { "伍家岗区""西陵区" });  
  209.         tmpProvince.put("湖北省", tmpCity);  
  210.         // 湖南省  
  211.         tmpCity = new Hashtable<String, String[]>();  
  212.         tmpCity.put("长沙市"new String[] { "长沙县""芙蓉区""开福区""天心区""雨花区""岳麓区" });  
  213.         tmpCity.put("常德市"new String[] { "鼎城区""武陵区" });  
  214.         tmpCity.put("郴州市"new String[] { "北湖区""苏仙区" });  
  215.         tmpCity.put("衡阳市"new String[] { "石鼓区""雁峰区""蒸湘区""珠晖区" });  
  216.         tmpCity.put("怀化市"new String[] { "鹤城区" });  
  217.         tmpCity.put("娄底市"new String[] { "娄星区" });  
  218.         tmpCity.put("邵阳市"new String[] { "北塔区""大祥区""双清区" });  
  219.         tmpCity.put("湘潭市"new String[] { "雨湖区""岳塘区" });  
  220.         tmpCity.put("益阳市"new String[] { "赫山区""资阳区" });  
  221.         tmpCity.put("岳阳市"new String[] { "君山区""岳阳楼区""云溪区" });  
  222.         tmpCity.put("张家界市"new String[] { "武陵源区""永定区" });  
  223.         tmpCity.put("株洲市"new String[] { "荷塘区""芦淞区""石峰区""天元区" });  
  224.         tmpCity.put("永州市"new String[] { "冷水滩区" });  
  225.         tmpCity.put("湘西土家族苗族自治州"new String[] { "吉首市" });  
  226.         tmpProvince.put("湖南省", tmpCity);  
  227.         // // 吉林省  
  228.         tmpCity = new Hashtable<String, String[]>();  
  229.         tmpCity.put("白城市"new String[] { "洮北区" });  
  230.         tmpCity.put("白山市"new String[] { "八道江区" });  
  231.         tmpCity.put("长春市"new String[] { "朝阳区""二道区""宽城区""绿园区""南关区" });  
  232.         tmpCity.put("吉林市"new String[] { "昌邑区""船营区""丰满区""龙潭区" });  
  233.         tmpCity.put("辽源市"new String[] { "龙山区""西安区" });  
  234.         tmpCity.put("四平市"new String[] { "铁东区""铁西区" });  
  235.         tmpCity.put("松原市"new String[] { "宁江区""前郭尔罗斯蒙古族自治县" });  
  236.         tmpCity.put("通化市"new String[] { "东昌区""二道江区""梅河口市" });  
  237.         tmpCity.put("延边朝鲜族自治州"new String[] { "珲春市""延吉市" });  
  238.         tmpProvince.put("吉林省", tmpCity);  
  239.         // 江苏省  
  240.         tmpCity = new Hashtable<String, String[]>();  
  241.         tmpCity.put("常州市"new String[] { "金坛市""溧阳市""戚墅堰区""天宁区""武进区""新北区""钟楼区" });  
  242.         tmpCity.put("淮安市"new String[] { "楚州区""淮阴区""金湖县""涟水县""清河区""青浦区""盱眙县" });  
  243.         tmpCity.put("连云港市"new String[] { "东海县""赣榆县""灌南县""灌云县""海州区""连云区""新浦区" });  
  244.         tmpCity.put("南京市"new String[] { "白下区""鼓楼区""建邺区""江宁区""六合区""浦口区""栖霞区""秦淮区",  
  245.                 "玄武区""雨花台区""下关区" });  
  246.         tmpCity.put("南通市"new String[] { "崇川区""港闸区""海安县""海门市""启东市""如东县""如皋市""通州市" });  
  247.         tmpCity.put("苏州市"new String[] { "沧浪区""常熟市""虎丘区""金阊区""昆山市""平江区""太仓市""吴江市",  
  248.                 "吴中区""相城区""张家港市" });  
  249.         tmpCity.put("宿迁市"new String[] { "宿城区""宿豫区" });  
  250.         tmpCity.put("泰州市"new String[] { "海陵区""姜堰市""兴化市""高港区""靖江市" });  
  251.         tmpCity.put("无锡市"new String[] { "北塘区""滨湖区""崇安区""惠山区""江阴市""南长区""锡山区""宜兴区" });  
  252.         tmpCity.put("徐州市"new String[] { "丰县""鼓楼区""九里区""邳州市""泉山区""新沂市""云龙区""铜山县" });  
  253.         tmpCity.put("盐城市"new String[] { "滨海县""大丰市""东台市""建湖县""亭湖区""盐都县""盐都新区" });  
  254.         tmpCity.put("扬州市"new String[] { "宝应县""高邮市""广陵区""邗江区""江都市""维扬区""仪征区" });  
  255.         tmpCity.put("镇江市"new String[] { "丹徒区""丹阳市""京口区""句容市""润州区""扬中市" });  
  256.         tmpProvince.put("甘肃省", tmpCity);  
  257.         // 江西省  
  258.         tmpCity = new Hashtable<String, String[]>();  
  259.         tmpCity.put("抚州市"new String[] { "临川区" });  
  260.         tmpCity.put("赣州市"new String[] { "章贡区" });  
  261.         tmpCity.put("景德镇市"new String[] { "昌江区""珠山区""乐平市""昌江区" });  
  262.         tmpCity.put("九江市"new String[] { "庐山区""浔阳区" });  
  263.         tmpCity.put("南昌市"new String[] { "东湖区""南昌县""青山湖区""青云谱区""湾里区""西湖区""新建县" });  
  264.         tmpCity.put("萍乡市"new String[] { "安源区""湘东区" });  
  265.         tmpCity.put("上饶市"new String[] { "信州区" });  
  266.         tmpCity.put("新余市"new String[] { "渝水区" });  
  267.         tmpCity.put("宜春市"new String[] { "袁州区" });  
  268.         tmpCity.put("鹰潭市"new String[] { "月湖区" });  
  269.         tmpCity.put("吉安市"new String[] { "吉州区""青原区" });  
  270.         tmpProvince.put("江西省", tmpCity);  
  271.         // 辽宁省  
  272.         tmpCity = new Hashtable<String, String[]>();  
  273.         tmpCity.put("鞍山市"new String[] { "海城市""立山区""千山区""台安县""铁东区""铁西区""岫岩满族自治县" });  
  274.         tmpCity.put("本溪市"new String[] { "本溪满族自治县""桓仁满族自治县""明山区""平山区""溪湖区" });  
  275.         tmpCity.put("朝阳市"new String[] { "北票市""朝阳县""建平县""喀喇沁左翼蒙古族自治县""凌源市""龙城区""双塔区" });  
  276.         tmpCity.put("大连市"new String[] { "甘井子区""金州区""旅顺口区""普兰店市""沙河口区""瓦房店市""西岗区",  
  277.                 "中山区""庄河市" });  
  278.         tmpCity.put("丹东市"new String[] { "东港市""凤城市""宽甸满族自治县""元宝区""振安区""振兴区" });  
  279.         tmpCity.put("抚顺市"new String[] { "抚顺县""顺城区""望花区""新抚区" });  
  280.         tmpCity.put("阜新市"new String[] { "阜新蒙古族自治县""海州区""清河门区""太平区""细河区""新邱区""彰武区" });  
  281.         tmpCity.put("葫芦岛市"new String[] { "建昌县""连山区""龙港区""绥中县""兴城市" });  
  282.         tmpCity.put("锦州市"new String[] { "古塔区""黑山县""凌海市""凌河区""太和区""义县    " });  
  283.         tmpCity.put("辽阳市"new String[] { "白塔区""灯塔市""弓长岭区""宏伟区""辽阳县""太子河区""文圣区" });  
  284.         tmpCity.put("盘锦市"new String[] { "大洼县""盘山县""双台子区""兴隆台区" });  
  285.         tmpCity.put("沈阳市"new String[] { "大东区""东陵区""法库县""和平区""皇姑区""康平县""辽中县""沈河区",  
  286.                 "苏家屯区""铁西区""沈北新区""新民市""于洪区""浑南新区" });  
  287.         tmpCity.put("铁岭市"new String[] { "昌图县""调兵山市""开原市""清河区""铁岭县""银州区" });  
  288.         tmpCity.put("营口市"new String[] { "鲅鱼圈区""大石桥市""盖州市""西市区""站前区""老边区" });  
  289.         tmpProvince.put("辽宁省", tmpCity);  
  290.         // 内蒙古自治区  
  291.         tmpCity = new Hashtable<String, String[]>();  
  292.         tmpCity.put("巴彦淖尔市"new String[] { "临河区" });  
  293.         tmpCity.put("包头市"new String[] { "东河区""昆都仑区""青山区""九原区" });  
  294.         tmpCity.put("赤峰市"new String[] { "红山区""松山区" });  
  295.         tmpCity.put("鄂尔多斯市"new String[] { "东胜区" });  
  296.         tmpCity.put("呼和浩特市"new String[] { "回民区""新城区""玉泉区""赛罕区" });  
  297.         tmpCity.put("呼伦贝尔市"new String[] { "海拉尔区" });  
  298.         tmpCity.put("通辽市"new String[] { "科尔沁区" });  
  299.         tmpCity.put("乌海市"new String[] { "海勃湾区""海南市""乌达区" });  
  300.         tmpCity.put("乌兰察布市"new String[] { "集宁区" });  
  301.         tmpCity.put("锡林郭勒盟"new String[] { "锡林浩特市" });  
  302.         tmpCity.put("兴安盟"new String[] { "乌兰浩特市" });  
  303.         tmpCity.put(""new String[] {});  
  304.         tmpProvince.put("内蒙古自治区", tmpCity);  
  305.         // 宁夏回族自治区  
  306.         tmpCity = new Hashtable<String, String[]>();  
  307.         tmpCity.put("固原市"new String[] { "原州区" });  
  308.         tmpCity.put("石嘴山市"new String[] { "大武口区""惠农区" });  
  309.         tmpCity.put("吴忠市"new String[] { "利通区" });  
  310.         tmpCity.put("银川市"new String[] { "金凤区""西夏区""兴庆区" });  
  311.         tmpCity.put("中卫市"new String[] { "沙坡头区" });  
  312.         tmpProvince.put("宁夏回族自治区", tmpCity);  
  313.         // 青海省  
  314.         tmpCity = new Hashtable<String, String[]>();  
  315.         tmpCity.put("海西蒙古族藏族自治州"new String[] { "格尔木市" });  
  316.         tmpCity.put("西宁市"new String[] { "城北区""城东区""城西区""城中区" });  
  317.         tmpProvince.put("青海省", tmpCity);  
  318.         // 山东省  
  319.         tmpCity = new Hashtable<String, String[]>();  
  320.         tmpCity.put("滨州市"new String[] { "滨城区""博兴县""惠民县""无棣县""邹平县" });  
  321.         tmpCity.put("德州市"new String[] { "德城区""齐河县""禹城市" });  
  322.         tmpCity.put("东营市"new String[] { "东营区""广饶县" });  
  323.         tmpCity.put("菏泽市"new String[] { "曹县""单县""巨野县""牡丹区""郓城县" });  
  324.         tmpCity.put("济南市"new String[] { "长清区""槐荫区""历城区""历下区""平阴县""市中区""天桥区""章丘市" });  
  325.         tmpCity.put("济宁市"new String[] { "金乡县""梁山县""曲阜市""市中区""泗水县""任城区" });  
  326.         tmpCity.put("莱芜市"new String[] { "钢城区""莱城区" });  
  327.         tmpCity.put("聊城市"new String[] { "东阿县""东昌府区""临清市""阳谷县" });  
  328.         tmpCity.put("临沂市"new String[] { "河东区""兰山区""罗庄区""沂水县" });  
  329.         tmpCity.put("青岛市"new String[] { "城阳区""黄岛区""即墨市""胶南市""胶州市""莱西市""崂山区""李沧区",  
  330.                 "平度市""市北区""市南区""四方区" });  
  331.         tmpCity.put("日照市"new String[] { "东港区""莒县""五莲县" });  
  332.         tmpCity.put("泰安市"new String[] { "岱岳区""泰山区""新泰市" });  
  333.         tmpCity.put("威海市"new String[] { "环翠区""乳山市""文登市" });  
  334.         tmpCity.put("潍坊市"new String[] { "昌乐县""昌邑市""坊子区""高密市""寒亭区""奎文区""青州市""潍城区",  
  335.                 "寿光市""诸城市" });  
  336.         tmpCity.put("烟台市"new String[] { "福山区""海阳市""莱山区""莱阳市""莱州市""龙口市""牟平区""蓬莱市",  
  337.                 "栖霞市""招远市""芝罘区""开发区" });  
  338.         tmpCity.put("枣庄市"new String[] { "市中区""滕州市""山亭区""薛城区""峄城区" });  
  339.         tmpCity.put("淄博市"new String[] { "博山区""临淄区""沂源县""张店区""周村区""淄川区" });  
  340.         tmpProvince.put("山东省", tmpCity);  
  341.         // 山西省  
  342.         tmpCity = new Hashtable<String, String[]>();  
  343.         tmpCity.put("长治市"new String[] { "城区" });  
  344.         tmpCity.put("大同市"new String[] { "城区""矿区""南郊区" });  
  345.         tmpCity.put("晋城市"new String[] { "城区""泽州县" });  
  346.         tmpCity.put("晋中市"new String[] { "榆次区" });  
  347.         tmpCity.put("临汾市"new String[] { "侯马市""尧都区" });  
  348.         tmpCity.put("吕梁市"new String[] { "离石区""柳林县" });  
  349.         tmpCity.put("朔州市"new String[] { "朔州市" });  
  350.         tmpCity.put("太原市"new String[] { "古交市""尖草坪区""晋源区""万柏林区""小店区""杏花岭区""迎泽区" });  
  351.         tmpCity.put("忻州市"new String[] { "忻府区" });  
  352.         tmpCity.put("阳泉市"new String[] { "城区""郊区""矿区" });  
  353.         tmpCity.put("运城市"new String[] { "河津市""盐湖区" });  
  354.         tmpProvince.put("山西省", tmpCity);  
  355.         // 陕西省  
  356.         tmpCity = new Hashtable<String, String[]>();  
  357.         tmpCity.put("安康市"new String[] { "汉滨区" });  
  358.         tmpCity.put("宝鸡市"new String[] { "金台区""渭滨区" });  
  359.         tmpCity.put("汉中市"new String[] { "汉台区""南郑县" });  
  360.         tmpCity.put("商洛市"new String[] { "商州区" });  
  361.         tmpCity.put("铜川市"new String[] { "王益区""耀州区""印台区" });  
  362.         tmpCity.put("渭南市"new String[] { "临渭区" });  
  363.         tmpCity.put("西安市"new String[] { "灞桥区""碑林区""长安区""莲湖区""临潼区""未央区""新城区""阎良区",  
  364.                 "雁塔区""西高经济技术产业开发区" });  
  365.         tmpCity.put("咸阳市"new String[] { "秦都区""渭城区""兴平市""杨陵区" });  
  366.         tmpCity.put("延安市"new String[] { "宝塔区" });  
  367.         tmpCity.put("榆林市"new String[] { "榆阳区" });  
  368.         tmpProvince.put("陕西省", tmpCity);  
  369.         // 上海市  
  370.         tmpCity = new Hashtable<String, String[]>();  
  371.         tmpCity.put("上海市"new String[] { "宝山区""长宁区""崇明县""奉贤区""虹口区""黄浦区""嘉定区""金山区",  
  372.                 "静安区""卢湾区""闵行区""南汇区""浦东新区""普陀区""青浦区""松江区""徐汇区""杨浦区""闸北区" });  
  373.         tmpProvince.put("上海市", tmpCity);  
  374.         // 四川省  
  375.         tmpCity = new Hashtable<String, String[]>();  
  376.         tmpCity.put("巴中市"new String[] { "巴州区" });  
  377.         tmpCity.put("成都市"new String[] { "成华区""金牛区""锦江区""龙泉驿区""青白江区""青羊区""双流县""温江区",  
  378.                 "武侯区""新都区""郫县" });  
  379.         tmpCity.put("达州市"new String[] { "通川区" });  
  380.         tmpCity.put("德阳市"new String[] { "广汉市""旌阳区""什邡市" });  
  381.         tmpCity.put("广元市"new String[] { "市中区""利州区" });  
  382.         tmpCity.put("广安市"new String[] { "广安区" });  
  383.         tmpCity.put("乐山市"new String[] { "市中区" });  
  384.         tmpCity.put("凉山彝族自治州"new String[] { "西昌市" });  
  385.         tmpCity.put("泸州市"new String[] { "江阳区""龙马潭区""纳溪区" });  
  386.         tmpCity.put("眉山市"new String[] { "东坡区" });  
  387.         tmpCity.put("绵阳市"new String[] { "涪城区""江油市""盐亭县""游仙区" });  
  388.         tmpCity.put("内江市"new String[] { "东兴区""市中区" });  
  389.         tmpCity.put("南充市"new String[] { "高坪区""嘉陵区""顺庆区" });  
  390.         tmpCity.put("攀枝花市"new String[] { "东区" });  
  391.         tmpCity.put("遂宁市"new String[] { "船山区" });  
  392.         tmpCity.put("雅安市"new String[] { "雨城区" });  
  393.         tmpCity.put("宜宾市"new String[] { "翠屏区" });  
  394.         tmpCity.put("资阳市"new String[] { "雁江区" });  
  395.         tmpCity.put("自贡市"new String[] { "大安区""贡井区""自流井区" });  
  396.         tmpProvince.put("四川省", tmpCity);  
  397.         // 天津市  
  398.         tmpCity = new Hashtable<String, String[]>();  
  399.         tmpCity.put("天津市"new String[] { "宝坻区""北辰区""大港区""东丽区""汉沽区""和平区""河北区""河东区",  
  400.                 "河西区""红桥区""蓟县""津南区""静海县""南开区""宁河县""塘沽区""武清区""西青区" });  
  401.         tmpProvince.put("天津市", tmpCity);  
  402.         // 西藏自治区  
  403.         tmpCity = new Hashtable<String, String[]>();  
  404.         tmpCity.put("拉萨市"new String[] { "城关区" });  
  405.         tmpCity.put("日喀则地区"new String[] { "日喀则市" });  
  406.         tmpCity.put("林芝地区"new String[] { "林芝县" });  
  407.         tmpProvince.put("西藏自治区", tmpCity);  
  408.         // 云南省  
  409.         tmpCity = new Hashtable<String, String[]>();  
  410.         tmpCity.put("保山市"new String[] { "隆阳区" });  
  411.         tmpCity.put("楚雄彝族自治州"new String[] { "楚雄市" });  
  412.         tmpCity.put("大理白族自治州"new String[] { "大理市" });  
  413.         tmpCity.put("德宏傣族景颇族自治州"new String[] { "潞西市""瑞丽市" });  
  414.         tmpCity.put("迪庆藏族自治州"new String[] { "香格里拉县" });  
  415.         tmpCity.put("红河哈尼族彝族自治州"new String[] { "个旧市""开远市""蒙自县""弥勒县" });  
  416.         tmpCity.put("昆明市"new String[] { "官渡区""盘龙区""五华区""西山区" });  
  417.         tmpCity.put("丽江市"new String[] { "古城区" });  
  418.         tmpCity.put("临沧市"new String[] { "思茅区" });  
  419.         tmpCity.put("曲靖市"new String[] { "麒麟区""宣威市" });  
  420.         tmpCity.put("文山壮族苗族自治州"new String[] { "文山县" });  
  421.         tmpCity.put("西双版纳傣族自治州"new String[] { "景洪市""勐海县" });  
  422.         tmpCity.put("玉溪市"new String[] { "红塔区" });  
  423.         tmpCity.put("昭通市"new String[] { "昭阳区" });  
  424.         tmpCity.put(""new String[] {});  
  425.         tmpProvince.put("云南省", tmpCity);  
  426.         // 浙江省  
  427.         tmpCity = new Hashtable<String, String[]>();  
  428.         tmpCity.put("杭州市"new String[] { "滨江区,淳安县""富阳市""拱墅区""建德市""江干区""临安市""上城区",  
  429.                 "桐庐县""西湖区""下城区""萧山区""余杭区" });  
  430.         tmpCity.put("湖州市"new String[] { "长兴县""德清县""南浔区""吴兴区" });  
  431.         tmpCity.put("嘉兴市"new String[] { "海宁市""海盐县""平湖市""桐乡市""南湖区""秀洲区" });  
  432.         tmpCity.put("金华市"new String[] { "东阳市""金东区""兰溪市""浦江县""武义县""婺城区""义乌市""永康市" });  
  433.         tmpCity.put("丽水市"new String[] { "缙云县""莲都区""龙泉市""青田县""松阳县""遂昌县""云和县" });  
  434.         tmpCity.put("宁波市"new String[] { "北仑区""慈溪市""奉化市""海曙区""江北区""江东区""宁海县""象山县",  
  435.                 "鄞州区""余姚市""镇海区" });  
  436.         tmpCity.put("衢州市"new String[] { "常山县""江山市""开化县""柯城区""龙游县""衢江区" });  
  437.         tmpCity.put("绍兴市"new String[] { "上虞市""绍兴县""嵊州市""新昌县""越城区""诸暨市" });  
  438.         tmpCity.put("台州市"new String[] { "黄岩区""椒江区""临海市""路桥区""三门县""天台县""温岭市""仙居县",  
  439.                 "玉环县" });  
  440.         tmpCity.put("温州市"new String[] { "苍南县""乐清市""龙湾区""鹿城区""瓯海区""平阳区""瑞安市""永嘉市" });  
  441.         tmpCity.put("舟山市"new String[] { "定海区""普陀区" });  
  442.         tmpProvince.put("浙江省", tmpCity);  
  443.         // 新疆维吾尔自治区  
  444.         tmpCity = new Hashtable<String, String[]>();  
  445.         tmpCity.put("阿克苏地区"new String[] { "阿克苏市""库车县" });  
  446.         tmpCity.put("阿勒泰地区"new String[] { "阿勒泰市" });  
  447.         tmpCity.put("巴音郭楞蒙古自治州"new String[] { "库尔勒市""轮台县""焉耆回族自治县" });  
  448.         tmpCity.put("博尔塔拉蒙古自治州"new String[] { "博乐市" });  
  449.         tmpCity.put("昌吉回族自治州"new String[] { "昌吉市" });  
  450.         tmpCity.put("哈密地区"new String[] { "哈密市" });  
  451.         tmpCity.put("喀什地区"new String[] { "喀什市" });  
  452.         tmpCity.put("克拉玛依市"new String[] { "克拉玛依区""独子山区" });  
  453.         tmpCity.put("克孜勒苏柯尔克孜自治州"new String[] { "阿图什市" });  
  454.         tmpCity.put("石河子市"new String[] {});  
  455.         tmpCity.put("乌鲁木齐市"new String[] { "米泉\\石化""沙依巴克区""水磨沟区""天山区""新市区""经济开发区" });  
  456.         tmpCity.put("伊犁哈萨克自治州"new String[] { "奎屯市""伊宁市" });  
  457.         tmpCity.put("塔城地区"new String[] { "乌苏市" });  
  458.         tmpProvince.put("新疆维吾尔自治区", tmpCity);  
  459.         return tmpProvince;  
  460.     }  
  461.   
  462.     /** 
  463.      * @param table 
  464.      *            地区总表。 
  465.      * @param type 
  466.      *            获取的地区类别。 
  467.      * @param args 
  468.      *            指定的地区参数。 
  469.      * */  
  470.     public static String[] findAreaStringArr(Hashtable<String, Hashtable<String, String[]>> table,  
  471.             int type, String... args) {  
  472.         String[] arr = null;  
  473.         if (table == null) {  
  474.             return null;  
  475.         }  
  476.         if (type == TYPE_PROVINCE) {  
  477.             arr = getKeyArrayByTable(table);  
  478.         } else if (type == TYPE_CITY) {  
  479.             String province = null;  
  480.             for (String tmp : args) {  
  481.                 province = tmp;  
  482.                 if (province != null) {  
  483.                     break;  
  484.                 }  
  485.             }  
  486.             Hashtable<String, String[]> tmpCity = table.get(province);  
  487.             arr = getKeyArrayByTable(tmpCity);  
  488.         } else if (type == TYPE_REGION) {  
  489.             String province = null, city = null;  
  490.             for (String tmp : args) {  
  491.                 if (province == null) {  
  492.                     province = tmp;  
  493.                 } else {  
  494.                     city = tmp;  
  495.                     break;  
  496.                 }  
  497.             }  
  498.             Hashtable<String, String[]> tmpCity = table.get(province);  
  499.             arr = tmpCity.get(city);  
  500.         }  
  501.         return arr;  
  502.     }  
  503.   
  504.       
  505.     public static String[] getKeyArrayByTable(Hashtable<String, ? extends Object> table) {  
  506.         String[] arr = null;  
  507.         Set<String> set = table.keySet();  
  508.         String[] tmp = new String[set.size()];  
  509.         Iterator<String> iterator = set.iterator();  
  510.         int count = 0;  
  511.         while (iterator.hasNext()) {  
  512.             tmp[count++] = iterator.next().toString();  
  513.         }  
  514.         arr = tmp;  
  515.         return arr;  
  516.     }  
  517.   
  518.     public static final List<String> arr2List(String[] arr) {  
  519.         List<String> list = null;  
  520.         if (arr != null) {  
  521.             list = new ArrayList<String>();  
  522.             for (int i = 0; i < arr.length; i++) {  
  523.                 list.add(arr[i]);  
  524.             }  
  525.         }  
  526.         return list;  
  527.     }  
  528. }  

原文地址:点击打开链接

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值