use of org.smpp.util.ByteBuffer in project opensmpp by OpenSmpp.
the class TLVUByte method getValueData.
/**
* Creates byt buffer containing one unsigned byte.
* @return the byte buffer with one unsingned byte
*/
protected ByteBuffer getValueData() throws ValueNotSetException {
ByteBuffer valueBuf = new ByteBuffer();
valueBuf.appendByte(encodeUnsigned(getValue()));
return valueBuf;
}
use of org.smpp.util.ByteBuffer in project opensmpp by OpenSmpp.
the class TLV method getData.
/**
* Returns the binary TLV created from tag, length and binary data value
* carried by this TLV.
*/
public ByteBuffer getData() throws ValueNotSetException {
if (hasValue()) {
ByteBuffer tlvBuf = new ByteBuffer();
tlvBuf.appendShort(getTag());
tlvBuf.appendShort(encodeUnsigned(getLength()));
tlvBuf.appendBuffer(getValueData());
return tlvBuf;
} else {
return null;
}
}
use of org.smpp.util.ByteBuffer in project opensmpp by OpenSmpp.
the class TLV method setData.
/**
* Overwrites <code>ByteData</code>'s <code>setData</code> and parses
* tag, length and the binary data value from the buffer. For parsing the
* data value calls abstract <code>setValueData</code>.
*/
public void setData(ByteBuffer buffer) throws NotEnoughDataInByteBufferException, TLVException {
short newTag = buffer.removeShort();
int length = buffer.removeShort();
ByteBuffer valueBuf = buffer.removeBuffer(length);
setValueData(valueBuf);
setTag(newTag);
}
use of org.smpp.util.ByteBuffer in project opensmpp by OpenSmpp.
the class ByteBufferTest method testAppendByte1.
@Test
public void testAppendByte1() {
buffer = new ByteBuffer(new byte[] {});
buffer.appendByte(t_bite);
assertBufferMatches(t_bite);
}
use of org.smpp.util.ByteBuffer in project opensmpp by OpenSmpp.
the class AddressTest method testGetData.
@Test
public void testGetData() throws Exception {
for (byte ton : TONS) {
for (byte npi : NPIS) {
for (int len = 1; len <= MAX_ADDRESS_LENGTH; len++) {
String a = address(len);
address = new Address(ton, npi, a, len + 1);
ByteBuffer buffer = address.getData();
assertEquals(ton, buffer.removeByte());
assertEquals(npi, buffer.removeByte());
assertEquals(a, buffer.removeCString());
}
}
}
}
Aggregations