Logica lastest SMPP API
源代码在线查看: message.java
package com.smpp.server;
import com.logica.smpp.pdu.DeliverSM;
public class Message {
// mandatory parameters
private String serviceType;
private String sourceAddress;
private String destAddress;
private String[] destAddrArray;
private byte protocolId;
private short smLength;
private String shortMessage;
private int seqNo;
private int ServiceId;
private boolean isMulti = false;
public Message() {
}
public Message(DeliverSM deliverSM) {
serviceType = deliverSM.getServiceType();
sourceAddress = deliverSM.getSourceAddr().getAddress();
destAddress = deliverSM.getSourceAddr().getAddress();
protocolId = deliverSM.getProtocolId();
smLength = deliverSM.getSmLength();
shortMessage = deliverSM.getShortMessage();
}
private Message(Message message) {
serviceType = message.getServiceType();
sourceAddress = message.getSourceAddress();
destAddress = message.getDestAddress();
protocolId = message.getProtocolId();
smLength = message.getSmLength();
shortMessage = message.getShortMessage();
}
public String debugString() {
String dbgs = "(Message ::>> ";
dbgs += "Source Address = " + sourceAddress;
dbgs += " ";
dbgs += "Destination Address = " + destAddress;
dbgs += " ";
dbgs += "Message = " + shortMessage;
dbgs += " ";
dbgs += "Message Length= " + smLength;
dbgs += " ";
dbgs += "Protocol ID = " + protocolId;
dbgs += " ";
dbgs += "Service Type = " + serviceType;
dbgs += " ";
dbgs += ") ";
return dbgs;
}
/**
* @return Returns the destAddress.
*/
public String getDestAddress() {
return destAddress;
}
/**
* @return Returns the protocolId.
*/
public byte getProtocolId() {
return protocolId;
}
/**
* @return Returns the serviceType.
*/
public String getServiceType() {
return serviceType;
}
/**
* @return Returns the shortMessage.
*/
public String getShortMessage() {
return shortMessage;
}
/**
* @return Returns the smLength.
*/
public short getSmLength() {
return smLength;
}
/**
* @return Returns the sourceAddress.
*/
public String getSourceAddress() {
return sourceAddress;
}
/**
* @param destAddress
* The destAddress to set.
*/
public void setDestAddress(String destAddress) {
this.destAddress = destAddress;
}
/**
* @param protocolId
* The protocolId to set.
*/
public void setProtocolId(byte protocolId) {
this.protocolId = protocolId;
}
/**
* @param serviceType
* The serviceType to set.
*/
public void setServiceType(String serviceType) {
this.serviceType = serviceType;
}
/**
* @param shortMessage
* The shortMessage to set.
*/
public void setShortMessage(String shortMessage) {
this.shortMessage = shortMessage;
}
/**
* @param smLength
* The smLength to set.
*/
public void setSmLength(short smLength) {
this.smLength = smLength;
}
/**
* @param sourceAddress
* The sourceAddress to set.
*/
public void setSourceAddress(String sourceAddress) {
this.sourceAddress = sourceAddress;
}
/**
* @return Returns the seqNo.
*/
public int getSeqNo() {
return seqNo;
}
/**
* @param seqNo
* The seqNo to set.
*/
public void setSeqNo(int seqNo) {
this.seqNo = seqNo;
}
/**
* @return Returns the serviceId.
*/
public int getServiceId() {
return ServiceId;
}
/**
* @param serviceId
* The serviceId to set.
*/
public void setServiceId(int serviceId) {
ServiceId = serviceId;
}
public String[] getDestAddrArray() {
return destAddrArray;
}
public void setDestAddrArray(String[] destAddrArray) {
isMulti = true;
this.destAddrArray = destAddrArray;
}
public boolean isMulti() {
return isMulti;
}
public Message[] getMessages(Message message) {
Message[] m = null;
if (isMulti == false) {
m = new Message[1];
m[0] = message;
} else
{
String [] da = message.getDestAddrArray();
m = new Message[da.length];
for(int i = 0 ; i < da.length ; i ++)
{
Message mt = new Message(message);
mt.setDestAddress(da[i]);
m[i] = mt;
}
}
return m;
}
}