📄 gateway.java
字号:
package com.gctech.sms.core;
import java.util.Map;
/**
* <p>Title: 网关常量。</p>
* <p>Description: 网关常量。</p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: gctech</p>
* @author 王红宝
* @version $Id: Gateway.java,v 1.9 2004/11/15 06:13:24 lijz Exp $
*/
public class Gateway {
//网关编号规则:1开头表示网通,后加上区号代表各省
//网通
public static final Gateway TELECOM = new Gateway(2, "网通");
public static final Gateway TELECOMBJ = new Gateway(22, "北京网通");
//中国移动
public static final Gateway CHINA_MOBILE = new Gateway(0, "中国移动");
//联通
public static final Gateway UNICOM = new Gateway(1, "联通");
//山东移动
public static final Gateway SHAN_DONG_MOBILE = new Gateway(8, "山东移动");
//add by lijz@gctech.com.cn
// public static final Gateway BJ_CNC_MOBILE = new Gateway(1010, "北京网通");
public static final Gateway HERB_CNC_MOBILE = new Gateway(10451, "哈尔滨网通");
public static final Gateway TJ_CNC_MOBILE = new Gateway(23, "天津网通");
public static final Gateway SD_CNC_MOBILE = new Gateway(24, "山东网通");
public static final Gateway HB_CNC_MOBILE = new Gateway(25, "河北网通");
//测试网关
public static final Gateway SIMU_GATEWAY = new Gateway(99, "测试网关");
static Map all = new java.util.TreeMap();
static {
all.put(new Integer(CHINA_MOBILE.getValue()), CHINA_MOBILE);
all.put(new Integer(TELECOM.getValue()), TELECOM);
all.put(new Integer(TELECOMBJ.getValue()), TELECOMBJ);
all.put(new Integer(UNICOM.getValue()), UNICOM);
all.put(new Integer(SIMU_GATEWAY.getValue()), SIMU_GATEWAY);
all.put(new Integer(SHAN_DONG_MOBILE.getValue()), SHAN_DONG_MOBILE);
// all.put(new Integer(BJ_CNC_MOBILE.getValue()), BJ_CNC_MOBILE);
all.put(new Integer(HERB_CNC_MOBILE.getValue()), HERB_CNC_MOBILE);
all.put(new Integer(TJ_CNC_MOBILE.getValue()), TJ_CNC_MOBILE);
all.put(new Integer(SD_CNC_MOBILE.getValue()), SD_CNC_MOBILE);
all.put(new Integer(HB_CNC_MOBILE.getValue()), HB_CNC_MOBILE);
}
public static java.util.Collection getAll() {
return all.values();
}
public static String valueToName(int value) {
Gateway type = (Gateway) all.get(new Integer(value));
return type.getName();
}
public Gateway(int value, String name) {
this.name = name;
this.value = value;
}
private String name;
private int value;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
public static int getGateway(String dest) {
if (dest.matches("0[0-9]{9,10}")) {
if (dest.startsWith("010")) {
return TELECOMBJ.getValue();
} else if (dest.startsWith("022")) {
return TJ_CNC_MOBILE.getValue();
} else if (
dest.startsWith("053")
|| dest.startsWith("063")
|| dest.startsWith("0543")
|| dest.startsWith("0546")) {
return SD_CNC_MOBILE.getValue();
} else if (dest.startsWith("031")) {
return HB_CNC_MOBILE.getValue();
} else {
return Gateway.TELECOM.getValue();
}
}
//移动网关
else if (dest.matches("13[0-9]{9}")) {
return Gateway.CHINA_MOBILE.getValue();
} else {
throw new IllegalArgumentException("没有号码对应的网关 " + dest);
}
}
public static int getGatewayBySpId(String dest, String spId) {
if (spId.equals("BJDST") || spId.equals("JSHD"))
return TELECOM.value;
if (spId.equals("VOXSMS")) {
if (dest.startsWith("010"))
return TELECOM.value;
else
return getGateway(dest);
}
if (spId.equals("ZhangXun"))
return TELECOM.value;
else
return getGateway(dest);
}
public static String getSpIdByGateway(int gateway) {
if (gateway == SHAN_DONG_MOBILE.getValue())
return "DWZB";
else if (gateway == TJ_CNC_MOBILE.getValue()) {
return "VOXSMS";
} else if (gateway == TELECOM.getValue()) {
return "VOXSMS";
} else
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -