org.mobicents.protocols.smpp.util
Class PacketEncoderImpl

java.lang.Object
  extended by org.mobicents.protocols.smpp.util.PacketEncoderImpl
All Implemented Interfaces:
PacketEncoder

public class PacketEncoderImpl
extends Object
implements PacketEncoder

Implementation of the PacketEncoder interface.

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

Constructor Summary
PacketEncoderImpl()
           
PacketEncoderImpl(OutputStream stream)
           
 
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[] bytes)
           
 PacketEncoder writeBytes(byte[] bytes, 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PacketEncoderImpl

public PacketEncoderImpl()

PacketEncoderImpl

public PacketEncoderImpl(OutputStream stream)
Method Detail

setStream

public PacketEncoder setStream(OutputStream out)
Description copied from interface: PacketEncoder
Set the output stream this encoder is writing to.

Specified by:
setStream in interface PacketEncoder
Parameters:
out - The output stream to write to.
Returns:
This packet encoder.

getStream

public OutputStream getStream()
Description copied from interface: PacketEncoder
Get the stream this encoder is writing to.

Specified by:
getStream in interface PacketEncoder
Returns:
The stream this encoder is writing to.

writeCString

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

Specified by:
writeCString in interface PacketEncoder
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

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

Specified by:
writeString in interface PacketEncoder
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.

writeUInt1

public PacketEncoder writeUInt1(int value)
                         throws IOException
Description copied from interface: PacketEncoder
Write a 1-byte unsigned integer to the output stream.

Specified by:
writeUInt1 in interface PacketEncoder
Parameters:
value - The integer value to send.
Returns:
This packet encoder.
Throws:
IOException - If a problem occurs writing to the stream.

writeUInt2

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

Specified by:
writeUInt2 in interface PacketEncoder
Parameters:
value - The integer value to send.
Returns:
This packet encoder.
Throws:
IOException - If a problem occurs writing to the stream.

writeUInt4

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

Specified by:
writeUInt4 in interface PacketEncoder
Parameters:
value - The integer value to send.
Returns:
This packet encoder.
Throws:
IOException - If a problem occurs writing to the stream.

writeInt4

public PacketEncoder writeInt4(int value)
                        throws IOException
Description copied from interface: PacketEncoder
Write a 4-byte integer to the output stream in big-endian order.

Specified by:
writeInt4 in interface PacketEncoder
Parameters:
value - The integer value to send.
Returns:
This packet encoder.
Throws:
IOException - If a problem occurs writing to the stream.

writeInt8

public PacketEncoder writeInt8(long value)
                        throws IOException
Description copied from interface: PacketEncoder
Write an 8-byte integer to the output stream in big-endian order.

Specified by:
writeInt8 in interface PacketEncoder
Parameters:
value - The integer value to send.
Returns:
This packet encoder.
Throws:
IOException - If a problem occurs writing to the stream.

writeAddress

public PacketEncoder writeAddress(Address address)
                           throws IOException
Description copied from interface: PacketEncoder
Write an SMPP address to the output stream.

Specified by:
writeAddress in interface PacketEncoder
Parameters:
address - The address to write to the stream.
Returns:
This packet encoder.
Throws:
IOException - If a problem occurs writing to the stream.

writeErrorAddress

public PacketEncoder writeErrorAddress(ErrorAddress errorAddress)
                                throws IOException
Description copied from interface: PacketEncoder
Write an SMPP error address to the output stream.

Specified by:
writeErrorAddress in interface PacketEncoder
Returns:
This packet encoder.
Throws:
IOException - If a problem occurs while writing.

writeDate

public PacketEncoder writeDate(SMPPDate date)
                        throws IOException
Description copied from interface: PacketEncoder
Write an SMPP date to the output stream.

Specified by:
writeDate in interface PacketEncoder
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

public PacketEncoder writeBytes(byte[] bytes)
                         throws IOException
Specified by:
writeBytes in interface PacketEncoder
Throws:
IOException

writeBytes

public PacketEncoder writeBytes(byte[] bytes,
                                int offset,
                                int length)
                         throws IOException
Description copied from interface: PacketEncoder
Write a byte array to the output stream.

Specified by:
writeBytes in interface PacketEncoder
Parameters:
bytes - 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.


Copyright © 2011 Mobicents. All Rights Reserved.