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

📄 smmessage.java

📁 WAP PUSH后台源码,WAP PUSH后台源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package com.tssx.ebiz.sgip;
import java.util.*;


public class SMMessage {

     /** GSM优先级,最低优先级 */
     public static final int LOWEST_PRIORITY = 0;
     /** GSM优先级,一般优先级 */
     public static final int NORMAL_PRIORITY = 1;
     /** GSM优先级,最高优先级,在GSM短消息系统中和一般优先级同等对待 */
     public static final int HIGHEST_PRIORITY = 3;

     /** 短消息发送状态,未处理状态 */
     public static final int NOT_IN_PROCESSING = 0;
     /** 短消息发送状态,正在处理状态 */
     public static final int IN_PROCESSING = 1;

     /** 短消息类型,单发地址短消息 */
     public static final int SINGLE_SMS_SEND = 0;
     /** 短消息类型,多发地址短消息 */
     public static final int MULTI_SMS_SEND = 1;

     /** 短消息类型,多发地址短消息 */
     public static final int BINARY_SMS_SEND = 2;
     /** 短消息在短消息队列中的ID */
     protected long queueID;
     /** 短消息源地址 */
     protected String sourceAddr;
     /** 短消息目的地址 */
     protected String destinationAddr;

     /** 多地址发送短消息的地址数组 */
     protected String[] destAddr;

     /** 短消息优先级 */
     protected int priorityFlag;
     /** 短消息设定发送时间 */
     protected Date scheduleTime;
     /** 短消息设定废弃时间 */
     protected Date validatyPeriod;
     /** 短消息尝试发送次数 */
     protected int sendCount;
     /** 短消息发送状态 */
     protected int sendStat;
     /** 短消息类型 */
     protected int submitMulti;
     protected int fileNum;
     /** 短消息内容 */
     protected String content;

     protected String spNumber;
     protected String corpID;
     protected String serviceType;
     protected int feeType;
     protected String feeValue;
     protected String givenValue;
     protected int morelatetoMTFlag;
     protected int reportFlag;
     protected byte[] binaryContent;
     protected String[] contentMulti;
     protected byte[][] binaryContentMulti;

     /**
      * 初始化函数,创建一个空的短消息对象
      */
     public SMMessage() throws SMParameterException {
          smInit(null, "000000000000", LOWEST_PRIORITY, null, null, null);
     }

     /**
      * 初始化函数,按给定参数创建一个短消息对象
      * @param whichDestAddr 指定接收者的地址
      * @param msgBody 要发送的消息体
      * @exception 接收者地址或短消息内容长度不正确
      */
     public SMMessage(String destinationAddr, String content)
               throws SMParameterException {
          smInit(null, destinationAddr, LOWEST_PRIORITY, null, null, content);
     }

     /**
      * 初始化函数,按给定参数创建一个短消息对象
      * @param sourceAddr 短消息发送者的标示,一般指手机号码,可以为空
      * @param destAddr 短消息接收者的标示,一般指手机号码
      * @param priorityFlag 短消息的发送优先级,输入非法值取0,不产生异常
      * @param schduleTime 短消息的指定发送时间
      * @param validatyPeriod 短消息的废弃时间
      * @param msg 短消息消息体,长度不能超过140位
      * @exception SMParameterExceptionn 接收者地址格式或长度错误,或消息体长度错误,或非法时间值
      */
     public SMMessage(String sourceAddr,
                      String destinationAddr,
                      int priorityFlag,
                      Date scheduleTime,
                      Date validatyPeriod,
                      String content)
               throws SMParameterException {
          smInit(sourceAddr, destinationAddr, priorityFlag, scheduleTime, validatyPeriod, content);
     }

     /**
      * 初始化函数,按给定参数创建一个多发地址短消息对象
      * @param destAddr 短消息接收者的标示,一般指手机号码,包含一组接收者地址,自动删除重复的地址
      * @param msg 短消息消息体,长度不能超过140位
      * @exception SMParameterExceptionn 接收者地址格式或长度错误,或消息体长度错误
      */
     public SMMessage(String[] destAddr, String content)
               throws SMParameterException {
          smInit(null, destAddr, LOWEST_PRIORITY, null, null, content);

     }

     /**
      * 初始化函数,按给定参数创建一个多发地址短消息对象
      * @param sourceAddr 短消息发送者的标示,一般指手机号码,可以为空
      * @param destAddr 短消息接收者的标示,一般指手机号码,包含一组接收者地址,自动删除重复的地址
      * @param priorityFlag 短消息的发送优先级,输入非法值取0
      * @param schduleTime 短消息的指定发送时间
      * @param validatyPeriod 短消息的废弃时间
      * @param msg 短消息消息体,长度不能超过140位
      * @exception SMParameterExceptionn 接收者地址格式或长度错误,或消息体长度错误,或非法时间值
      */
     public SMMessage(String sourceAddr,
                      String[] destAddr,
                      int priorityFlag,
                      Date scheduleTime,
                      Date validatyPeriod,
                      String content)
               throws SMParameterException {
          smInit(sourceAddr, destAddr, priorityFlag, scheduleTime, validatyPeriod, content);
     }

     /**
      * 获取短消息在队列中的消息ID
      * @return >0 短消息在消息队列中的ID, =0 新短消息,尚未保存到数据库中
      */
     public long getQueueID() {
          return this.queueID;
     }

     /**
      * 获取短消息的源地址信息
      * @return 短消息的源地址,为空表示没有源地址
      */
     public String getSourceAddr() {
          return this.sourceAddr;
     }

     /**
      * 获取短消息的接收者地址信息
      * @return 短消息的接收者地址信息,为空表示没有接收者地址
      */
     public String getDestinationAddr() {
          return this.destinationAddr;
     }

     /**
      * 获取短消息的发送优先级
      * @return 短消息的发送优先级
      */
     public int getPriorityFlag() {
          return this.priorityFlag;
     }

     /**
      * 获取短消息的发送设定时间
      * @return 短消息的发送设定时间
      */
     public Date getScheduleTime() {
          return this.scheduleTime;
     }

     /**
      * 获取短消息的废弃设定时间
      * @return 短消息的废弃设定时间
      */
     public Date getValidatyPeriod() {
          return this.validatyPeriod;
     }

     /**
      * 获取短消息的发送计数
      * @return 短消息的发送计数
      */
     public int getSendCount() {
          return this.sendCount;
     }

     /**
      * 获取多发地址短消息的接收者地址
      * @return 短消息的接收者地址数组
      */
     public String[] getDestAddr() {
          return this.destAddr;
     }

     /**
      * 判断短消息的是否多发地址短消息
      * @return true 是多发地址短消息,false 是单发地址短消息
      */
     public boolean isMultiMsg() {
          return this.submitMulti == MULTI_SMS_SEND;
     }

     public boolean isBinaryMsg() {
          return this.submitMulti == BINARY_SMS_SEND;
     }
     /**
      * 判断短消息的发送状态
      * @return true 短消息正在发送中, false 短消息不处于发送中状态
      */
     public boolean isSending() {
          return this.sendStat == IN_PROCESSING;
     }

     /**
      * 设置短消息的发送源地址
      * @param theSourceAddr 短消息的发送源地址
      * @exception SMParameterExceptionn 接收者地址格式或长度错误,或消息体长度错误
      */
     public void setSourceAddr(String theSourceAddr)
              throws SMParameterException, SMQueueAccessException {

          if (!verifyAddr(theSourceAddr))
               throw new SMParameterException("Source Address Format Error!");
          this.sourceAddr = theSourceAddr;
     }

     /**
      * 设置短消息的接收者地址
      * @param theDestinationAddr 短消息的接收者地址
      * @exception SMParameterExceptionn 接收者地址格式或长度错误,或消息体长度错误
      */
     public void setDestinationAddr(String theDestinationAddr)
               throws SMParameterException, SMQueueAccessException {
          if (theDestinationAddr == null || !verifyAddr(theDestinationAddr))
               throw new SMParameterException("Destination Address Format Error!");
          this.destinationAddr = theDestinationAddr;
     }

     /**
      * 设置短消息的发送优先级
      * @param thePriotityFlag 短消息的发送优先级
      * @exception SMParameterExceptionn 接收者地址格式或长度错误,或消息体长度错误
      */
     public void setPriorityFlag(int thePriorityFlag)
               throws SMParameterException, SMQueueAccessException {
//          if (thePriorityFlag < LOWEST_PRIORITY && thePriorityFlag > HIGHEST_PRIORITY)
//               throw new SMParameterException("Priority Format Error!");
          this.priorityFlag = thePriorityFlag;
     }

     /**
      * 设置短消息的发送设定时间
      * @param theScheduleTime 短消息的发送设定时间
      * @exception SMParameterExceptionn 接收者地址格式或长度错误,或消息体长度错误
      */
     public void setScheduleTime(Date theScheduleTime)
               throws SMParameterException, SMQueueAccessException {
          this.scheduleTime = theScheduleTime;
     }

     /**
      * 设置短消息的废弃设定时间
      * @param theValidatyPeriod 短消息的废弃设定时间
      * @exception SMParameterExceptionn 接收者地址格式或长度错误,或消息体长度错误
      */
     public void setValidatyPeriod(Date theValidatyPeriod)
               throws SMParameterException, SMQueueAccessException {
          this.validatyPeriod = theValidatyPeriod;
     }

     /**
      * 设置短消息的发送计数
      * @param count 短消息的发送计数值
      */
     public void setSendCount(int theSendCount)
               throws SMParameterException, SMQueueAccessException {
          if (theSendCount < 0) throw new SMParameterException();
          this.sendCount = theSendCount;
     }

     /**
      * 设置短消息的发送状态
      * @param stat 短消息的发送状态
      */
     public void setSendStat(int theSendStat)
               throws SMParameterException, SMQueueAccessException {
          if (theSendStat != IN_PROCESSING && theSendStat != NOT_IN_PROCESSING)
               throw new SMParameterException();
          this.sendStat = theSendStat;
     }

     /**
      * 设置多发地址短消息的接收者地址
      * @param multiDestAddr 多发地址短消息的接收者地址数组
      * @exception SMParameterExceptionn 接收者地址格式或长度错误,或消息体长度错误
      */
     public void setDestAddr(String[] theDestAddr)
               throws SMParameterException, SMQueueAccessException {
          if (theDestAddr == null
              || theDestAddr.length < 1
              || !verifyAddr(theDestAddr))
               throw new SMParameterException("Destination Address Format Error!");
          setMultiMsgFlag(true);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -