throws NotEnoughDataInByteBufferException, UnexpectedOptionalParameterException, TLVException {
short tag;
short length;
ByteBuffer tlvHeader;
ByteBuffer tlvBuf;
TLV tlv = null;
while (buffer.length() > 0) {
// we prepare buffer with one parameter
tlvHeader = buffer.readBytes(Data.TLV_HEADER_SIZE);
tag = tlvHeader.removeShort();
tlv = findOptional(optionalParameters, tag);
if (tlv == null) {
// ok, got extra optional parameter not defined in SMPP spec
// will keep it as octets
tlv = new TLVOctets(tag);
registerExtraOptional(tlv);
}
length = tlvHeader.removeShort();
tlvBuf = buffer.removeBuffer(Data.TLV_HEADER_SIZE + length);
tlv.setData(tlvBuf);
}
}