|
||||||||||
| 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 | |
|---|---|
java.lang.Object |
clone()
|
boolean |
equals(java.lang.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. |
java.lang.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. |
java.lang.Object |
removeTLV(Tag tag)
Remove a TLV parameter. |
protected boolean |
safeCompare(java.lang.Object obj1,
java.lang.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. |
java.lang.Object |
setTLV(Tag tag,
java.lang.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(java.lang.String string)
Get the encoded size of a string, which may be null. |
java.lang.String |
toString()
Return a String representation of this packet. |
protected void |
toString(java.lang.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 java.lang.Object setTLV(Tag tag,
java.lang.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 java.lang.Object getTLV(Tag tag)
getTLVTable().get(tag).
tag - the tag of the TLV parameter to get.public java.lang.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 java.io.IOException
out - The OutputStream to use
java.io.IOException - if there's an error writing to the output stream.
public final void writeTo(PacketEncoder encoder,
boolean withOptional)
throws java.io.IOException
out - The OutputStream to usewithOptional - true to send optional parameters over the link, false to only
write the mandatory parameters.
java.io.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 java.lang.String toString()
toString in class java.lang.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(java.lang.String string)
null.
string - A (possibly null) string object.
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in class java.lang.Objectjava.lang.CloneNotSupportedExceptionpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object
protected boolean safeCompare(java.lang.Object obj1,
java.lang.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(java.lang.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 java.io.IOException
encoder - The encoder to write mandatory parameters to.
java.io.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 | |||||||||