|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mobicents.protocols.smpp.message.SMPPPacket
public abstract class SMPPPacket
This is the abstract class that all SMPP messages are inherited from.
| Field Summary | |
|---|---|
protected int |
commandId
Command ID. |
protected int |
commandStatus
Command status. |
protected long |
sequenceNum
Packet sequence number. |
protected TLVTable |
tlvTable
TLV table. |
| Constructor Summary | |
|---|---|
protected |
SMPPPacket(int commandId)
Create a new SMPPPacket with the specified Id. |
protected |
SMPPPacket(SMPPPacket request)
Create a new SMPPPacket that represents a response to the specified packet. |
| Method Summary | |
|---|---|
Object |
clone()
|
boolean |
equals(Object obj)
|
int |
getCommandId()
Get the Command Id of this SMPP packet. |
int |
getCommandStatus()
Get the status of this packet. |
int |
getLength()
Get the length this packet encodes as. |
protected int |
getMandatorySize()
Get the encoded size of the mandatory parameters of this packet. |
long |
getSequenceNum()
Get the sequence number of this packet. |
Object |
getTLV(Tag tag)
Get a TLV parameter. |
TLVTable |
getTLVTable()
Get the optional parameter (TLV) table. |
int |
hashCode()
|
boolean |
isRequest()
Is this command a request packet. |
boolean |
isResponse()
Is this command a response packet. |
boolean |
isSet(Tag tag)
Check if a particular TLV parameter is set. |
void |
readFrom(PacketDecoder decoder)
Decode an SMPP packet from a byte array. |
protected void |
readMandatory(PacketDecoder decoder)
Read the mandatory parameters from a packet decoder. |
Object |
removeTLV(Tag tag)
Remove a TLV parameter. |
protected boolean |
safeCompare(Object obj1,
Object obj2)
Utility method to compare two objects, even if one or both are null. |
void |
setCommandStatus(int commandStatus)
Set the status of this packet. |
void |
setSequenceNum(long sequenceNum)
Set the sequence number of this packet. |
Object |
setTLV(Tag tag,
Object value)
Set a TLV parameter. |
int |
sizeOf(Address address)
Get the encoded size of an address, which may be null. |
int |
sizeOf(byte[] array)
Get the encoded size of a byte array, which may be null. |
int |
sizeOf(SMPPDate date)
Get the encoded size of a date, which may be null. |
int |
sizeOf(String string)
Get the encoded size of a string, which may be null. |
String |
toString()
Return a String representation of this packet. |
protected void |
toString(StringBuilder buffer)
Get the mandatory parameters in string form (for display purposes only). |
void |
validate(SMPPVersion smppVersion)
Validate this packet against an SMPP version. |
protected void |
validateMandatory(SMPPVersion smppVersion)
Validate the mandatory parameters for this packet. |
protected boolean |
validateTLVTable(SMPPVersion smppVersion)
Validate that the TLV table contains all required parameters. |
protected void |
writeMandatory(PacketEncoder encoder)
Write the mandatory parameters to a packet encoder. |
void |
writeTo(PacketEncoder encoder)
Write the byte representation of this SMPP packet to an OutputStream |
void |
writeTo(PacketEncoder encoder,
boolean withOptional)
Write the byte representation of this SMPP packet to an OutputStream |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected int commandId
protected int commandStatus
protected long sequenceNum
protected TLVTable tlvTable
| Constructor Detail |
|---|
protected SMPPPacket(int commandId)
commandId - The command ID.protected SMPPPacket(SMPPPacket request)
request - | Method Detail |
|---|
public boolean isRequest()
true if this packet is an SMPP request,
false if it is a response.public boolean isResponse()
true if this packet is an SMPP response,
false if it is a request.public int getCommandId()
public int getCommandStatus()
public void setCommandStatus(int commandStatus)
commandStatus - public long getSequenceNum()
public void setSequenceNum(long sequenceNum)
public TLVTable getTLVTable()
TLVTable
public Object setTLV(Tag tag,
Object value)
getTLVTable().put(tag, value).
tag - The tag of the parameter to set.value - The value object to set.
BadValueTypeException - If the type of value is incorrect for the
tag.TLVTable.put(org.mobicents.protocols.smpp.message.tlv.Tag, char)public Object getTLV(Tag tag)
getTLVTable().get(tag).
tag - the tag of the TLV parameter to get.public Object removeTLV(Tag tag)
getTLVTable().remove(tag).
tag - The TLV to remove.
null if it wasn't.public boolean isSet(Tag tag)
getTLVTable().containsKey(tag)
.
tag - the tag of the parameter to check.
public final int getLength()
public void writeTo(PacketEncoder encoder)
throws IOException
out - The OutputStream to use
IOException - if there's an error writing to the output stream.
public final void writeTo(PacketEncoder encoder,
boolean withOptional)
throws IOException
out - The OutputStream to usewithOptional - true to send optional parameters over the link, false to only
write the mandatory parameters.
IOException - if there's an error writing to the output stream.
public void readFrom(PacketDecoder decoder)
throws SMPPProtocolException
data - the byte array to read the SMPP packet's fields from.offset - the offset into b to begin reading the packet
fields from.
SMPPProtocolException - if there is an error parsing the packet fields.
SMPPRuntimeException - If an attempt is made to parse a different
type of packet than this class supports (for example, trying to use
a BindTransmitter object to parse data that contains a
BindTransceiver packet).public final void validate(SMPPVersion smppVersion)
smppVersion, a
VersionException will be thrown.
Examples of violations are:
smppVersion - The version to validate against.
VersionException - If the package fails validation.public String toString()
toString in class Objectpublic int sizeOf(Address address)
null.
address - A (possibly null) address object.
public int sizeOf(SMPPDate date)
null.
date - A (possibly null) date object.
public int sizeOf(byte[] array)
null.
array - A (possibly null) byte array.
public int sizeOf(String string)
null.
string - A (possibly null) string object.
public Object clone()
throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedExceptionpublic boolean equals(Object obj)
equals in class Objectpublic int hashCode()
hashCode in class Object
protected boolean safeCompare(Object obj1,
Object obj2)
null.
obj1 - The first object to compare.obj2 - The second object to compare.
true if the objects are equal, or if they are
both null. false otherwise.protected void toString(StringBuilder buffer)
buffer - protected void validateMandatory(SMPPVersion smppVersion)
org.mobicents.smpp.version.VersionException should be
thrown.
smppVersion - The version to validate against.protected boolean validateTLVTable(SMPPVersion smppVersion)
smppVersion - The version to validate against. Since
required TLVs were only introduced in SMPP version 5.0, this
method will only ever be called when using a version that
is equivalent to or newer than that.
true if all required TLVs are set,
false otherwise.protected void readMandatory(PacketDecoder decoder)
decoder - The decoder to read fields from.
protected void writeMandatory(PacketEncoder encoder)
throws IOException
encoder - The encoder to write mandatory parameters to.
IOException - If an problem occurs while writing.protected int getMandatorySize()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||