package com.siro.tools;
public class JudgePhoneNum {
private static String CMCC = "CMCC";
private static String UNICOM = "UNICOM";
private static String TELECOM = "TELECOM";
private static String UNKNWON = "UNKNWON";
private static boolean isNumeric(String msg) {
for (int i = 0; i < msg.length(); i++) {
if (java.lang.Character.isDigit(msg.charAt(i))) {
continue;
}
return false;
}
return true;
}
public static String getOperater(String phoneNum) {
String head3 = "";
String head4 = "";
phoneNum = phoneNum.trim();
if (phoneNum == null || phoneNum.length() < 11) {
return UNKNWON;
} else {
if (phoneNum.startsWith("+")) {
phoneNum = phoneNum.substring(1);
}
if (phoneNum.startsWith("86")) {
phoneNum = phoneNum.substring(2);
}
}
if (phoneNum.length() != 11) {
return UNKNWON;
}
if (!isNumeric(phoneNum)) {
return UNKNWON;
}
head3 = phoneNum.substring(0, 3);
head4 = phoneNum.substring(0, 4);
if (head3.equals("135")
|| head3.equals("136")
|| head3.equals("137")
|| head3.equals("138")
|| head3.equals("139")
|| head3.equals("150")
|| head3.equals("151")
|| head3.equals("152")
|| head3.equals("157")
|| head3.equals("158")
|| head3.equals("159")
|| head3.equals("182")
|| head3.equals("187")
|| head3.equals("188")
|| head3.equals("147")) {
return CMCC;
}
if (head4.equals("1340")
|| head4.equals("1341")
|| head4.equals("1342")
|| head4.equals("1343")
|| head4.equals("1344")
|| head4.equals("1345")
|| head4.equals("1346")
|| head4.equals("1347")
|| head4.equals("1348")) {
return CMCC;
}
if (head3.equals("130")
|| head3.equals("131")
|| head3.equals("132")
|| head3.equals("145")
|| head3.equals("155")
|| head3.equals("156")
|| head3.equals("185")
|| head3.equals("186")) {
return UNICOM;
}
if (head3.equals("133")
|| head3.equals("153")
|| head3.equals("180")
|| head3.equals("189")) {
return TELECOM;
}
if (head4.equals("1349")) {
return TELECOM;
}
return UNKNWON;
}
public static void main(String[] args) {
System.out.println(JudgePhoneNum.getOperater("18243288210"));
}
}