org.mobicents.protocols.smpp.util
Interface PacketEncoder

All Known Implementing Classes:
PacketEncoderImpl

public interface PacketEncoder

Interface specification for a packet encoder.

Version:
$Id: PacketEncoder.java 457 2009-01-15 17:37:42Z orank $

Method Summary
 OutputStream getStream()
          Get the stream this encoder is writing to.
 PacketEncoder setStream(OutputStream out)
          Set the output stream this encoder is writing to.
 PacketEncoder writeAddress(Address address)
          Write an SMPP address to the output stream.
 PacketEncoder writeBytes(byte[] array)
           
 PacketEncoder writeBytes(byte[] array, int offset, int length)
          Write a byte array to the output stream.
 PacketEncoder writeCString(String value)
          Write a C-String (one that is terminated with a nul byte) to the output stream.
 PacketEncoder writeDate(SMPPDate date)
          Write an SMPP date to the output stream.
 PacketEncoder writeErrorAddress(ErrorAddress errorAddress)
          Write an SMPP error address to the output stream.
 PacketEncoder writeInt4(int value)
          Write a 4-byte integer to the output stream in big-endian order.
 PacketEncoder writeInt8(long value)
          Write an 8-byte integer to the output stream in big-endian order.
 PacketEncoder writeString(String value, int length)
          Write a string to the output stream.
 PacketEncoder writeUInt1(int value)
          Write a 1-byte unsigned integer to the output stream.
 PacketEncoder writeUInt2(int value)
          Write a 2-byte unsigned integer to the output stream in big-endian order.
 PacketEncoder writeUInt4(long value)
          Write a 4-byte unsigned integer to the output stream in big-endian order.
 

Method Detail

setStream

PacketEncoder setStream(OutputStream out)
Set the output stream this encoder is writing to.

Parameters:
out - The output stream to write to.
Returns:
This packet encoder.

getStream

OutputStream getStream()
Get the stream this encoder is writing to.

Returns:
The stream this encoder is writing to.

writeCString

PacketEncoder writeCString(String value)
                           throws IOException
Write a C-String (one that is terminated with a nul byte) to the output stream. The characters will be encoded using US-ASCII.

Parameters:
value - The string value to write. If value is null a single nul-byte will still be written.
Returns:
This packet encoder.
Throws:
IOException - If a problem occurs writing to the stream.

writeString

PacketEncoder writeString(String value,
                          int length)
                          throws IOException
Write a string to the output stream. The characters will be encoded using US-ASCII.

Parameters:
value - The string value to write.
length - The number of characters to write.
Returns:
This packet encoder.
Throws:
IOException - If a problem occurs writing to the stream.
IndexOutOfBoundsException - If length is longer than the number of characters in value.

writeUInt1

PacketEncoder writeUInt1(int value)
                         throws IOException
Write a 1-byte unsigned integer to the output stream.

Parameters:
value - The integer value to send.
Returns:
This packet encoder.
Throws:
IOException - If a problem occurs writing to the stream.

writeUInt2

PacketEncoder writeUInt2(int value)
                         throws IOException
Write a 2-byte unsigned integer to the output stream in big-endian order.

Parameters:
value - The integer value to send.
Returns:
This packet encoder.
Throws:
IOException - If a problem occurs writing to the stream.

writeUInt4

PacketEncoder writeUInt4(long value)
                         throws IOException
Write a 4-byte unsigned integer to the output stream in big-endian order.

Parameters:
value - The integer value to send.
Returns:
This packet encoder.
Throws:
IOException - If a problem occurs writing to the stream.

writeInt4

PacketEncoder writeInt4(int value)
                        throws IOException
Write a 4-byte integer to the output stream in big-endian order.

Parameters:
value - The integer value to send.
Returns:
This packet encoder.
Throws:
IOException - If a problem occurs writing to the stream.

writeInt8

PacketEncoder writeInt8(long value)
                        throws IOException
Write an 8-byte integer to the output stream in big-endian order.

Parameters:
value - The integer value to send.
Returns:
This packet encoder.
Throws:
IOException - If a problem occurs writing to the stream.

writeAddress

PacketEncoder writeAddress(Address address)
                           throws IOException
Write an SMPP address to the output stream.

Parameters:
address - The address to write to the stream.
Returns:
This packet encoder.
Throws:
IOException - If a problem occurs writing to the stream.

writeErrorAddress

PacketEncoder writeErrorAddress(ErrorAddress errorAddress)
                                throws IOException
Write an SMPP error address to the output stream.

Parameters:
address - The error address to write.
Returns:
This packet encoder.
Throws:
IOException - If a problem occurs while writing.

writeDate

PacketEncoder writeDate(SMPPDate date)
                        throws IOException
Write an SMPP date to the output stream.

Parameters:
date - The SMPP date to write to the stream.
Returns:
This packet encoder.
Throws:
IOException - If a problem occurs writing to the stream.

writeBytes

PacketEncoder writeBytes(byte[] array)
                         throws IOException
Throws:
IOException

writeBytes

PacketEncoder writeBytes(byte[] array,
                         int offset,
                         int length)
                         throws IOException
Write a byte array to the output stream.

Parameters:
array - The byte array to write bytes from.
offset - The offset to begin copying bytes from.
length - The number of bytes to write.
Returns:
This packet encoder.
Throws:
IOException - If a problem occurs writing to the stream.
IndexOutOfBoundsException - if there are insufficient bytes in the array to satisfy the length parameter.


Copyright © 2011 Mobicents. All Rights Reserved.