Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
executable file
·
138 lines (104 loc) · 3.25 KB

File metadata and controls

executable file
·
138 lines (104 loc) · 3.25 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package xml;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class RegionSax extends DefaultHandler {
static HashMap<String, String> cityMap;
static Map<String, Map> provinceCodeMap;
static Map<String, Map> countryCodeMap;
static List<String> countryList;
static List<String> countryNamesList;
static List<String> countryCodesList;
String countryCode = "";
String countryName;
final static String defaultContryCode = "1";
final static String defaultContryName = "�й�";
@Override
public void startDocument() throws SAXException {
// TODO Auto-generated method stub
super.startDocument();
countryCodeMap = new HashMap<String, Map>();
// װ�����й���code,���й�������
countryList = new ArrayList<String>();
countryNamesList = new ArrayList<String>();
countryCodesList = new ArrayList<String>();
}
public void startElement(String uri, String localName, String qName,
Attributes attributes) {
if (qName.equals("CountryRegion")) {
provinceCodeMap = new HashMap<String, Map>();
// �����ֶ���
countryCode = attributes.getValue(1);
countryName = attributes.getValue(0);
countryNamesList.add(countryName);
countryCodesList.add(countryCode);
}
}
@Override
public void endElement(String uri, String localName, String qName)
throws SAXException {
// TODO Auto-generated method stub
super.endElement(uri, localName, qName);
if (qName.equals("CountryRegion")) {
countryCodeMap.put(countryCode, provinceCodeMap);
}
}
@Override
public void characters(char[] ch, int start, int length)
throws SAXException {
// TODO Auto-generated method stub
super.characters(ch, start, length);
String data = new String(ch, start, length);
// System.out.println("data is " + data);
}
@Override
public void endDocument() throws SAXException {
// TODO Auto-generated method stub
super.endDocument();
System.out.println("size is " + countryCodeMap.size());
}
/**
* ���ݹ����룬ʡ���룬�����룬�õ�������
*
* @return
*/
String check(String countryCode, String proviceCode, String CityCode) {
if (countryCode.equals(""))
countryCode = defaultContryCode;
Map<String, Map> provinceCodemap = countryCodeMap.get(countryCode);
String city = null;
try {
Map<String, String> proMap = provinceCodemap.get(proviceCode);
city = proMap.get(CityCode);
} catch (NullPointerException myNull) {
System.out.println("��������");
}
if (city == null)
city = "unKnown";
System.out.println(city);
return city;
}
/**
* ���ݹ��������ع���code
*
* @param countryName
* @return
*/
String checkCountryCode(String countryName) {
// countryNamesList
Object[] names = countryNamesList.toArray();
int index = -1;
for (int i = 0; i < names.length; i++) {
if (names[i].equals(countryName)) {
index = i;
}
}
Object[] codes = countryCodesList.toArray();
System.out.println("�������� " + codes[index].toString());
return codes[index].toString();
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.