📄 cncparser.java
字号:
package cncgw.parser;/** * <p>Title: cncGateWay</p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: gramsoft</p> * @author lee * @version 1.0 */import java.io.*;import java.util.*;import cncgw.log.*;import cncgw.xsms.*;import cncgw.cncMain;import cncgw.smdb.SubmitDb;public class cncParser { private int db_id ; private int seq ; private String media_type = ""; private String service_type = ""; private String source_address = ""; private String old_source_address = ""; private String destination_address = ""; private String old_destination_address = ""; private byte esm_class = 0; private byte priority_flag = 0; private String schedule_delivery_time = ""; private String validity_peroid = ""; private byte registered_delivery_flag = 0; private byte replace_if_present_flag = 0; private byte data_coding = 1; private int sm_leng = 0; private String short_message_text = ""; private String old_short_message_text = ""; private String fee_Type = ""; private String fee_userType = ""; private String fee_terminal = ""; private String flag = ""; SubmitDb submitdb = new SubmitDb(); public boolean getSubmit(Vector is,conn_desc conn) { try { db_id = Integer.parseInt((String)is.get(0)); if(is.get(2)!=null) media_type = (String)is.get(2); if(is.get(3)!=null) service_type = (String)is.get(3); if(is.get(4)!=null) source_address = (String)is.get(4); if(is.get(5)!=null) destination_address = (String)is.get(5); if(is.get(6)!=null) esm_class = (byte) Integer.parseInt((String)is.get(6)); if(is.get(7)!=null) priority_flag = (byte) Integer.parseInt((String)is.get(6)); if(is.get(8)!=null) schedule_delivery_time = (String)is.get(8); if(is.get(9)!=null) validity_peroid = (String)is.get(9); if(is.get(10)!=null) registered_delivery_flag = (byte) Integer.parseInt((String)is.get(6)); if(is.get(11)!=null) replace_if_present_flag = (byte) Integer.parseInt((String)is.get(6)); if(is.get(12)!=null) data_coding = (byte) Integer.parseInt((String)is.get(6)); if(is.get(13)!=null) short_message_text = normalize((String)is.get(13)); if(is.get(14)!=null) fee_Type = (String)is.get(14); if(is.get(15)!=null) fee_userType = (String)is.get(15); if(is.get(16)!=null) fee_terminal = (String)is.get(16);//分解超长的短信 if(!short_message_text.equals("")) //普通短信 { if(!(old_short_message_text.equals(short_message_text)&&old_source_address.equals(source_address)&&old_destination_address.equals(destination_address))) { String[] msg = cncMain.split(short_message_text,120); xsmse_submit submit[] = new xsmse_submit[msg.length]; for (int i=0;i<submit.length;i++) { try{ submit[i] = new xsmse_submit(); submit[i].set_media_type(media_type); submit[i].set_service_type(service_type); submit[i].set_source_address(source_address); submit[i].set_destination_address(destination_address); submit[i].set_esm_class(esm_class); submit[i].set_priority_flag(priority_flag); submit[i].set_schedule_delivery_time(schedule_delivery_time); submit[i].set_validity_peroid(validity_peroid); submit[i].set_registered_delivery_flag(registered_delivery_flag); submit[i].set_replace_if_present_flag(replace_if_present_flag); submit[i].set_data_coding(data_coding);//均默认按 1:gb2312 submit[i].set_sm_length(msg[i].length()); submit[i].set_short_message_text(msg[i]); submit[i].set_fee_Type(fee_Type); submit[i].set_fee_userType(fee_userType); submit[i].set_fee_terminal(fee_terminal); submit[i].set_seqNo(conn.seq); }catch(OutOfBoundsException ex){ cncMain.errorlog("[错误]-发送数据库取出字段溢出:"+ex); throw ex; } submitdb.insertSeqByupdate(conn.seq,db_id); conn.seq++; if(conn.seq == 0x7fffffff) conn.seq = 1; } old_source_address = source_address; old_destination_address = destination_address; old_short_message_text = short_message_text; Vector pool = cncMain.messages; synchronized (pool) { for (int i=0;i<submit.length;i++){ pool.addElement(submit[i]); } } return true; } } }catch (Exception e) { cncMain.errorlog("[错误]-生成短信:"+e); } return false; } /** Normalizes the given string. */ static public String normalize(String s) { StringBuffer str = new StringBuffer(); int len = (s != null) ? s.length() : 0; for (int i = 0; i < len; i++) { char ch = s.charAt(i); switch (ch) { case '<': { str.append("<"); break; } case '>': { str.append(">"); break; } case '&': { str.append("&"); break; } case '"': { str.append("""); break; } case '\r': case '\n': { str.append("&#"); str.append(Integer.toString(ch)); str.append(';'); break; }default: { str.append(ch);} } } return str.toString(); } // normalize(String):String}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -