Search in sources :

Example 1 with NotEnoughDataInBufferException

use of com.zx.sms.codec.smpp.NotEnoughDataInBufferException in project SMSGate by Lihuanghe.

the class ByteBufUtil method readAddress.

/**
 * Read and create a new Address from a buffer.  Checks if there is
 * a minimum number of bytes readable from the buffer.
 * @param buffer
 * @return
 * @throws UnrecoverablePduException
 * @throws RecoverablePduException
 */
public static Address readAddress(ByteBuf buffer) throws UnrecoverablePduException, RecoverablePduException {
    // an address is at least 3 bytes long (ton, npi, and null byte)
    if (buffer.readableBytes() < 3) {
        throw new NotEnoughDataInBufferException("Parsing address", buffer.readableBytes(), 3);
    }
    Address address = new Address();
    address.read(buffer);
    return address;
}
Also used : Address(com.zx.sms.codec.smpp.Address) NotEnoughDataInBufferException(com.zx.sms.codec.smpp.NotEnoughDataInBufferException)

Aggregations

Address (com.zx.sms.codec.smpp.Address)1 NotEnoughDataInBufferException (com.zx.sms.codec.smpp.NotEnoughDataInBufferException)1