⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cncparser.java~1~

📁 cnc网通小灵通网关接口源码
💻 JAVA~1~
字号:
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.xsms.*;import cncgw.cncMain;public class cncParser  {  int id, int seq , String  media_type, String  service_type , String  source_address ,            String   destination_address, String  esm_class, String  priority_flag, String  schedule_delivery_time,            String   validity_peroid, String   registered_delivery_flag, String   replace_if_present_flag, String  data_coding, String  short_message_text,            String   fee_Type, String   fee_userType,  String   fee_terminal, String   flag  private int seq = "00000000000";  private String media_type = "";  private String service_type = "";  private String password = "";  private String subject = "";  private String content = "";  private byte fee_type = 2;  private int info_fee = 0;  private byte fee_utype = 0;  private String fee_user = "";  private String flag = "";  private String myorder = "";  private String curElement = "";  public  boolean getSubmit(Vector is) {    try {      int user_seq = Integer.parseInt((String)is.get(0));//id      from = normalize((String)is.get(1));   //src_addr      to = normalize((String)is.get(2));   //dst_addr      content = normalize((String)is.get(3));//short_msg      fee_type = (byte) Integer.parseInt(normalize((String)is.get(4)));//fee_type      info_fee = Integer.parseInt(normalize((String)is.get(5)));//info_fee      fee_utype = (byte) Integer.parseInt((String)is.get(6));//fee_utype      fee_user = normalize((String)is.get(7));//pfee_user      //flag      myorder = (String)is.get(9);//myorder      byte short_msg[] = new byte[140];      byte icp_id[] = cncMain.str2byte(cncMain.icpid ,7);      byte svc_type[] = new byte[6];      int msg_length=0;      svc_type[0] = 0x39;      svc_type[1] = 0x30;      svc_type[2] = 0x34;      svc_type[3] = 0x30;      svc_type[4] = 0;//9040/*计费类别	含义0	“短消息类型”为“发送”,对“计费用户号码”不计信息费,此类话单仅用于核减SP对称的信道费1	对“计费用户号码”免费2	对“计费用户号码”按条计信息费3	对“计费用户号码”按包月收取信息费4	对“计费用户号码”的信息费封顶5	对“计费用户号码”的收费是由SP实现*/      //byte pfee_type = pfee_type;//资费代码      //int pinfo_fee = pinfo_fee;//协议标识      byte proto_id = 1;/*消息模式:xxxxxxx1  是否需要状态报告xxxxxx1x  是否是控制类消息xxxxx1xx  是否是SIM卡操作,此项是v1.1的解决方案,当此位被设置,protocol id 将被设置为0x7f, 为了向下兼容,此为仍然有效,但建议直接通过设置protocol id的方式进行xxxx1xxx  UDHI Indicator,用于铃声,图标等类型的消息1111xxxx   保留*/      byte msg_mode = 0;//0表示不需要状态报告的非控制类消息,//优先级别//值范围0-9,优先级9最高      byte priority = 0;/*计费用户类型0:对目的终端MSISDN计费;1:对源终端MSISDN计费;2:对SP计费;3:对指定的计费用户收费*/      //byte pfee_utype = pfee_utype;//计费用户,如果计费用户类型为3,则本参数必须被设置;如果计费用户类型为其它值,此参数无效      byte[] pfee_user = cncMain.str2byte(fee_user,21);      byte validate[] = new byte[10];      validate[0] = 0;      byte schedule[] = new byte[2];      schedule[0] = 0;      byte src_addr[] = cncMain.str2byte(from,21);//接收用户数量destination user//取值范围为 1-255      byte du_count = 1;//接收消息的MSISDN号码      byte dst_addr[][] = new byte[10][15];      String cncPhone = to;//    dst_addr[0][0] = (byte)(new Integer(cncPhone.substring(0,1)).intValue());//    dst_addr[0][0] = 0x31;      dst_addr[0][0] = (byte)(new Integer(cncPhone.substring(0,1)).intValue()+48);      dst_addr[0][1] = (byte)(new Integer(cncPhone.substring(1,2)).intValue()+48);      dst_addr[0][2] = (byte)(new Integer(cncPhone.substring(2,3)).intValue()+48);      dst_addr[0][3] = (byte)(new Integer(cncPhone.substring(3,4)).intValue()+48);      dst_addr[0][4] = (byte)(new Integer(cncPhone.substring(4,5)).intValue()+48);      dst_addr[0][5] = (byte)(new Integer(cncPhone.substring(5,6)).intValue()+48);      dst_addr[0][6] = (byte)(new Integer(cncPhone.substring(6,7)).intValue()+48);      dst_addr[0][7] = (byte)(new Integer(cncPhone.substring(7,8)).intValue()+48);      dst_addr[0][8] = (byte)(new Integer(cncPhone.substring(8,9)).intValue()+48);      dst_addr[0][9] = (byte)(new Integer(cncPhone.substring(9,10)).intValue()+48);      dst_addr[0][10] = (byte)(new Integer(cncPhone.substring(10,11)).intValue()+48);      dst_addr[0][11] = 0;      byte data_coding = 15;//消息内容处理      String Content = content; //         Content = content;//分解超长的短信if(!Content.equals("")) //普通短信     {     String[] msg = cncMain.split(Content,140);      xsmse_submit submit[] = new xsmse_submit[msg.length];      for (int i=0;i<submit.length;i++)      {        submit[i] = new xsmse_submit();        submit[i].set_icpid(icp_id);        submit[i].set_svctype(svc_type);        submit[i].set_feetype(fee_type);        submit[i].set_infofee(info_fee);        submit[i].set_protoid(proto_id);        submit[i].set_msgmode(msg_mode);        submit[i].set_priority(priority);        submit[i].set_validate(validate);        submit[i].set_schedule(schedule);        submit[i].set_feeutype(fee_utype);        submit[i].set_feeuser(pfee_user);        submit[i].set_srcaddr(src_addr);        submit[i].set_dstaddr(dst_addr);        submit[i].set_ducount(du_count);        short_msg = msg[i].getBytes();        submit[i].set_msg(data_coding,short_msg.length, short_msg);        submit[i].set_seqNo(user_seq);      }      Vector pool = cncMain.messages;      synchronized (pool) {        for (int i=0;i<submit.length;i++){          pool.addElement(submit[i]);        }      }    }    else//图片或铃声    {   xsmse_submit submit = new xsmse_submit();   submit.set_icpid(icp_id);   submit.set_svctype(svc_type);   submit.set_feetype(fee_type);   submit.set_infofee(info_fee);   submit.set_protoid(proto_id);   submit.set_msgmode(msg_mode);   submit.set_priority(priority);   submit.set_validate(validate);   submit.set_schedule(schedule);   submit.set_feeutype(fee_utype);   submit.set_feeuser(pfee_user);   submit.set_srcaddr(src_addr);   submit.set_dstaddr(dst_addr);   submit.set_ducount(du_count);   submit.set_msg(data_coding,msg_length, short_msg);   Vector pool = cncMain.messages;   synchronized (pool) {     pool.addElement(submit);   }    }    return true;    }    catch (Exception e)    {      cncMain.errorlog("[错误]生成短信:"+e);    }    return false;  }  /** Normalizes the given string. */    protected 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("&lt;");            break;          }        case '>': {          str.append("&gt;");          break;        }      case '&': {        str.append("&amp;");        break;      }    case '"': {      str.append("&quot;");      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 + -