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

📄 mmmessage.java

📁 nokia彩信发送api和实例
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * @(#)MMMessage.java	1.1  * * Copyright (c) Nokia Corporation 2002 * */package com.nokia.mms;import java.util.Date;import java.util.Hashtable;import java.util.Enumeration;import java.util.Vector;import java.io.Serializable;/** * The MMMEssage class represents a Multimedia Message. * */public class MMMessage implements IMMConstants, Serializable {  /* Internal Flags */  private boolean flagMultipartRelated=false;  /* Header Fields Flags */  private boolean flagBccAvailable=false;  private boolean flagCcAvailable=false;  private boolean flagContentTypeAvailable=false;  private boolean flagDateAvailable=false;  private boolean flagDeliveryReportAvailable=false;  private boolean flagDeliveryTimeAvailable=false;  private boolean flagDeliveryTimeAbsolute=false;  private boolean flagExpiryAvailable=false;  private boolean flagExpiryAbsolute=false;  private boolean flagFromAvailable=false;  private boolean flagMessageClassAvailable=false;  private boolean flagMessageIdAvailable=false;  private boolean flagMessageTypeAvailable=false;  private boolean flagMMSVersionAvailable=false;  private boolean flagPriorityAvailable=false;  private boolean flagReadReplyAvailable=false;  private boolean flagSenderVisibilityAvailable=false;  private boolean flagStatusAvailable=false;  private boolean flagSubjectAvailable=false;  private boolean flagToAvailable=false;  private boolean flagTransactionIdAvailable=false;  /* Header Fields */  private byte hMessageType;  private String hTransactionId="";  private String hMessageId="";  private byte hVersion=0;  private Vector hTo = null;  private Vector hCc = null;  private Vector hBcc = null;  private Date hReceivedDate;  private MMAddress hFrom=null;  private String hSubject="";  private byte hMessageClass=0;  private Date hExpiry;  private boolean hDeliveryReport=false;  private boolean hReadReply=false;  private byte hSenderVisibility=0;  private Date hDeliveryTime;  private byte hPriority;  private String hContentType="";  private byte hStatus;  /* Others variables */  private String multipartRelatedType="";  private String presentationId="";  private Hashtable tableOfContents=null;  /**   * Check if the presentation part is available.   *   * return true if availale.   */  public boolean isPresentationAvailable() {    return flagMultipartRelated;  }  /**   * Check if the message type field is available.   *   * return true if availale.   */  public boolean isMessageTypeAvailable() {    return flagMessageTypeAvailable;  }  /**   * Check if the Delivery-Report field is available.   *   * return true if availale.   */  public boolean isDeliveryReportAvailable() {    return flagDeliveryReportAvailable;  }  /**   * Check if the Sender-Visibility field is available.   *   * return true if availale.   */  public boolean isSenderVisibilityAvailable() {    return flagSenderVisibilityAvailable;  }  /**   * Check if the Read-Reply field is available.   *   * return true if availale.   */  public boolean isReadReplyAvailable() {    return flagReadReplyAvailable;  }  /**   * Check if the Status field is available.   *   * return true if availale.   */  public boolean isStatusAvailable() {    return flagStatusAvailable;  }  /**   * Check if the transaction ID field is available.   *   * return true if availale.   */  public boolean isTransactionIdAvailable() {    return flagTransactionIdAvailable;  }  /**   * Check if the message ID field is available.   *   * return true if availale.   */  public boolean isMessageIdAvailable() {    return flagMessageIdAvailable;  }  /**   * Check if the version field is available.   *   * return true if availale.   */  public boolean isVersionAvailable() {    return flagMMSVersionAvailable;  }  /**   * Check if the date field is available.   *   * return true if availale.   */  public boolean isDateAvailable() {    return flagDateAvailable;  }  /**   * Check if sender address field is available.   *   * return true if availale.   */  public boolean isFromAvailable() {    return flagFromAvailable;  }  /**   * Check if the subject field is available.   *   * return true if availale.   */  public boolean isSubjectAvailable() {    return flagSubjectAvailable;  }  /**   * Check if the message class field is available.   *   * return true if availale.   */  public boolean isMessageClassAvailable() {    return flagMessageClassAvailable;  }  /**   * Check if the expiry date/time field is available.   *   * return true if availale.   */  public boolean isExpiryAvailable() {    return flagExpiryAvailable;  }  /**   * Check if the delivery date/time field is available.   *   * return true if availale.   */  public boolean isDeliveryTimeAvailable() {    return flagDeliveryTimeAvailable;  }  /**   * Check if the priority date/time field is available.   *   * return true if availale.   */  public boolean isPriorityAvailable() {    return flagPriorityAvailable;  }  /**   * Check if the content type field is available.   *   * return true if availale.   */  public boolean isContentTypeAvailable() {    return flagContentTypeAvailable;  }  /**   * Check if there is at least one receiver is specified.   *   * return true if at least one receiver is specified.   */  public boolean isToAvailable() {    return flagToAvailable;  }  /**   * Check if there is at least one BCC receiver is specified.   *   * return true if at least one BCC receiver is specified.   */  public boolean isBccAvailable() {    return flagBccAvailable;  }  /**   * Check if there is at least one CC receiver is specified.   *   * return true if at least one CC receiver is specified.   */  public boolean isCcAvailable() {    return flagCcAvailable;  }  /**   * Returns the type of the message (Mandatory).   *   * return the type of the message.   * IMMConstants.MESSAGE_TYPE_M_SEND_REQ.   * IMMConstants.MESSAGE_TYPE_M_DELIVERY_IND.   */  public byte getMessageType() {    return hMessageType;  }  /**   * Sets the type of the message (Mandatory).   * Specifies the transaction type.   *   * param value the type of the message.   * IMMConstants.MESSAGE_TYPE_M_SEND_REQ.   * IMMConstants.MESSAGE_TYPE_M_DELIVERY_IND.   */  public void setMessageType(byte value) {    hMessageType = value;    flagMessageTypeAvailable = true;  }  /**   * Retrieves the Message ID (Mandatory).   * Identifier of the message. From Send request, connects delivery report to sent message in MS.   *   * return the message ID.   */  public String getMessageId() {    return hMessageId;  }  /**   * Sets the message ID (Mandatory).   * Identifier of the message. From Send request, connects delivery report to sent message in MS.   *   * param value the message ID.   */  public void setMessageId(String value) {    hMessageId = value;    flagMessageIdAvailable = true;  }  /**   * Retrieves the Message Status (Mandatory).   * The status of the message.   *   * return the message Status.   */  public byte getMessageStatus() {    return hStatus;  }  /**   * Sets the message Status (Mandatory).   * The status of the message.   *   * param value the message Status.   */  public void setMessageStatus(byte value) {    hStatus = value;    flagStatusAvailable = true;  }  /**   * Retrieves the transaction ID (Mandatory).   * It is a unique identifier for the message and it identifies the M-Send.req   * and the corresponding reply only.   *   * return the transaction ID.   */  public String getTransactionId() {    return hTransactionId;  }  /**   * Sets the transaction ID (Mandatory).   * It is a unique identifier for the message and it identifies the M-Send.req   * and the corresponding reply only.   *   * param value the trensaction ID.   */  public void setTransactionId(String value) {    hTransactionId = value;    flagTransactionIdAvailable = true;  }  /**   * Retrieves the MMS version number as a String(Mandatory).   *   * return the version as a String. The only supported value are "1.0" and "1.1".   */  public String getVersionAsString() {   int ver_major= ((byte)(hVersion<<1))>>5 ;   int ver_minor= ((byte)(hVersion<<4))>>4 ;   String result=ver_major+"."+ver_minor;   return result;  }  /**   * Retrieves the MMS version number (Mandatory).   *   * return the version. The only supported value are    * IMMConstants.MMS_VERSION_10 and IMMConstants.MMS_VERSION_11   */  public byte getVersion() {    return hVersion;  }  /**   * Sets the MMS version number (Mandatory).   *   * param value the only supported value are    * IMMConstants.MMS_VERSION_10 and IMMConstants.MMS_VERSION_11   */  public void setVersion(byte value) {    hVersion = value;    flagMMSVersionAvailable = true;  }  private MMAddress decodeAddress(String value) {    byte type = ADDRESS_TYPE_UNKNOWN;    String address=new String(value);    int sep = value.indexOf(47); // the character "/"    if(sep != -1) {       address = value.substring(0, sep);       if(value.endsWith("PLMN"))         type = ADDRESS_TYPE_PLMN;       else       if(value.endsWith("IPv4"))         type = ADDRESS_TYPE_IPV4;       else       if(value.endsWith("IPv6"))          type = ADDRESS_TYPE_IPV6;    }    else {     int at = address.indexOf(64); // the character "@"     if(at != -1)	type = ADDRESS_TYPE_EMAIL;    }    MMAddress result = new MMAddress(address,type);    return result;  }  /**   * Adds a new receiver of the Multimedia Message. The message can have   * more than one receiver but at least one.   *   * param value is the string representing the address of the receiver. It has   * to be specified in the full format i.e.: +358990000005/TYPE=PLMN or   * joe@user.org or 1.2.3.4/TYPE=IPv4.    *   */  public void addToAddress(String value) {    MMAddress addr = decodeAddress(value);    hTo.add(addr);    flagToAvailable = true;  }  /**   * Adds a new receiver in the CC (Carbon Copy) field of the Multimedia Message. The message can have   * more than one receiver in the CC field.   *   * param value is the string representing the address of the CC receiver. It has   * to be specified in the full format i.e.: +358990000005/TYPE=PLMN or   * joe@user.org or 1.2.3.4/TYPE=IPv4.    *   */  public void addCcAddress(String value) {    MMAddress addr = decodeAddress(value);    hCc.add(addr);    flagCcAvailable = true;  }  /**   * Adds a new receiver in the BCC (Blind Carbon Copy) field of the Multimedia Message. The message can have   * more than one receiver in the BCC field.   *   * param value is the string representing the address of the BCC receiver. It has   * to be specified in the full format i.e.: +358990000005/TYPE=PLMN or   * joe@user.org or 1.2.3.4/TYPE=IPv4.   *   */  public void addBccAddress(String value) {    MMAddress addr = decodeAddress(value);    hBcc.add(addr);    flagBccAvailable = true;

⌨️ 快捷键说明

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