📄 subapplication.java
字号:
package com.sms.platform.switchcenter.entity;
import java.io.File;
import java.util.*;
import com.sms.protocol.standard12.Standard_Inner_Deliver;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
import org.jdom.xpath.XPath;
public class SubApplication implements Comparator {
private int gatewayID;
private String longCode;
private String keyWord;
private int coagentID;
private int messageType;
public SubApplication() {
}
public int getCoagentID() {
return coagentID;
}
public int getGatewayID() {
return gatewayID;
}
public String getKeyWord() {
return keyWord;
}
public String getLongCode() {
return longCode;
}
public int getMessageType() {
return messageType;
}
public void setCoagentID(int coagentID) {
this.coagentID = coagentID;
}
public void setGatewayID(int gatewayID) {
this.gatewayID = gatewayID;
}
public void setKeyWord(String keyWord) {
this.keyWord = keyWord;
}
public void setLongCode(String longCode) {
this.longCode = longCode;
}
public void setMessageType(int messageType) {
this.messageType = messageType;
}
public int compare(Object element1, Object element2) {
SubApplication m1 = (SubApplication) element1;
SubApplication m2 = (SubApplication) element2;
if (m1.getLongCode().length() > m2.getLongCode().length()) {
return -1;
} else if (m1.getLongCode().length() == m2.getLongCode().length()) {
;
} else {
return 1;
}
if (m1.getKeyWord().length() > m2.getKeyWord().length()) {
return -1;
} else if (m1.getKeyWord().length() == m2.getKeyWord().length()) {
;
} else {
return 1;
}
if (m1.getGatewayID() > m2.getGatewayID()) {
return -1;
} else if (m1.getGatewayID() == m2.getGatewayID()) {
;
} else {
return 1;
}
return 0;
}
public static final int COMPARE_SUCCESS = 0;
public static final int COMPARE_FAIL_GWID = -1;
public static final int COMPARE_FAIL_LONGCODE = -2;
public static final int COMPARE_FAIL_KEYWORD = -3;
public int compare(int numgwid, String longcode, String keyword,
boolean isgwid) {
// System.out.println("-------------------------");
// System.out.println("GWID : " + this.getNUMGWID());
// System.out.println("LONGCODE : " + this.getVC2LONGCODE());
// System.out.println("LCMATCHDIR : " + this.getVC2LCMATCHDIR());
// System.out.println("CMD : " + this.getVC2CMD());
// System.out.println("CMDMATCHDIR : " + this.getVC2CMDMATCHDIR());
if (longcode == null) {
longcode = "";
}
if (keyword == null) {
keyword = "";
}
// 网关错误
if (this.getGatewayID() != numgwid && isgwid) {
return COMPARE_FAIL_GWID;
}
if (longcode.startsWith(this.getLongCode()) || longcode.equals("")) {
} else {
return COMPARE_FAIL_LONGCODE;
}
if (keyword.toUpperCase().startsWith(this.getKeyWord().toUpperCase())
|| keyword.equals("")) {
} else {
return COMPARE_FAIL_KEYWORD;
}
return COMPARE_SUCCESS;
}
public static boolean search(List<SubApplication> list,
Standard_Inner_Deliver sd) {
boolean ret = false;
for (int i = 0; i < list.size(); i++) {
SubApplication sr = list.get(i);
if (sr.compare(sd.getSrcClientID(), sd.getDestNumber(), sd
.getContentString(), false) == 0) {
sd.setDesClientID(sr.getCoagentID());
sd.setMessageType((short) sr.getMessageType());
ret = true;
break;
}
}
return ret;
}
public static List<SubApplication> loadSubmitRouter() throws Exception {
List<SubApplication> router = null;
SAXBuilder builder = new SAXBuilder();
File fileXml = new File("./memory/SubApplication.xml");
Document doc = builder.build(fileXml);
Element root = doc.getRootElement();
XPath xpath = XPath.newInstance("//sub/descendant-or-self::*");
List list = xpath.selectNodes(root);
Iterator iter = list.iterator();
router = new ArrayList<SubApplication>();
SubApplication sr = null;
while (iter.hasNext()) {
Element item = (Element) iter.next();
if (item.getName().equalsIgnoreCase("sub")) {
sr = new SubApplication();
continue;
} else if (item.getName().equalsIgnoreCase("gatewayID")) {
sr.setGatewayID(Integer.parseInt(item.getText()));
continue;
} else if (item.getName().equalsIgnoreCase("longCode")) {
sr.setLongCode(item.getText());
continue;
} else if (item.getName().equalsIgnoreCase("keyWord")) {
sr.setKeyWord(item.getText());
continue;
} else if (item.getName().equalsIgnoreCase("coagentID")) {
sr.setCoagentID(Integer.parseInt(item.getText()));
continue;
} else if (item.getName().equalsIgnoreCase("messageType")) {
sr.setMessageType(Integer.parseInt(item.getText()));
router.add(sr);
}
}
return router;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -