/** * Calculates and sets the commandLength for the PDU based on all currently * set values and optional parameters. * @return The calculated PDU command length */ public int calculateAndSetCommandLength() { int len = SmppConstants.PDU_HEADER_LENGTH + this.calculateByteSizeOfBody() + this.calculateByteSizeOfOptionalParameters(); this.setCommandLength(len); return len; }
/** * Checks if an optional parameter by tag exists. * @param tag The TLV to search for * @return True if exists, otherwise false */ public boolean hasOptionalParameter(short tag) { return (this.findOptionalParameter(tag) >= 0); }
PduResponse response = (PduResponse)pdu; if (response.getResultMessage() == null) { response.setResultMessage(context.lookupResultMessage(pdu.getCommandStatus())); if (!pdu.hasCommandLengthCalculated()) { pdu.calculateAndSetCommandLength(); ChannelBuffer buffer = new BigEndianHeapChannelBuffer(pdu.getCommandLength()); buffer.writeInt(pdu.getCommandLength()); buffer.writeInt(pdu.getCommandId()); buffer.writeInt(pdu.getCommandStatus()); buffer.writeInt(pdu.getSequenceNumber()); pdu.writeBody(buffer); pdu.writeOptionalParameters(buffer, context); if (buffer.readableBytes() != pdu.getCommandLength()) { throw new NotEnoughDataInBufferException("During PDU encoding the expected commandLength did not match the actual encoded (a serious error with our own encoding process)", pdu.getCommandLength(), buffer.readableBytes());
@Override public String toString() { StringBuilder buffer = new StringBuilder(65 + 300 + (getOptionalParameterCount()*20)); buffer.append(this.name); buffer.append(": 0x"); buffer.append(HexUtil.toHexString(getCommandLength())); buffer.append(" 0x"); buffer.append(HexUtil.toHexString(this.commandId)); buffer.append(HexUtil.toHexString(this.commandStatus)); buffer.append(" 0x"); buffer.append(HexUtil.toHexString(getSequenceNumber())); this.appendBodyToString(buffer); this.appendOptionalParameterToString(buffer); buffer.append(")");
/** * Sets an optional parameter by checking if the tag already exists in our * list of optional parameters. If it already exists, will replace the old * value with the new value. * @param tlv The TLV to add/set * @return Null if no TLV was replaced, or the TLV replaced. */ public Tlv setOptionalParameter(Tlv tlv) { // does this parameter already exist? int i = this.findOptionalParameter(tlv.getTag()); if (i < 0) { // parameter does not yet exist, add it, not replaced this.addOptionalParameter(tlv); return null; } else { // this parameter already exists, replace it, return old return this.optionalParameters.set(i, tlv); } }
public void readOptionalParameters(ChannelBuffer buffer, PduTranscoderContext context) throws UnrecoverablePduException, RecoverablePduException { // if there is any data left, it's part of an optional parameter while (buffer.readableBytes() > 0) { Tlv tlv = ChannelBufferUtil.readTlv(buffer); if (tlv.getTagName() == null) { tlv.setTagName(context.lookupTlvTagName(tlv.getTag())); } this.addOptionalParameter(tlv); } }
PduResponse response = (PduResponse)pdu; if (response.getResultMessage() == null) { response.setResultMessage(context.lookupResultMessage(pdu.getCommandStatus())); if (!pdu.hasCommandLengthCalculated()) { pdu.calculateAndSetCommandLength(); ChannelBuffer buffer = new BigEndianHeapChannelBuffer(pdu.getCommandLength()); buffer.writeInt(pdu.getCommandLength()); buffer.writeInt(pdu.getCommandId()); buffer.writeInt(pdu.getCommandStatus()); buffer.writeInt(pdu.getSequenceNumber()); pdu.writeBody(buffer); pdu.writeOptionalParameters(buffer, context); if (buffer.readableBytes() != pdu.getCommandLength()) { throw new NotEnoughDataInBufferException("During PDU encoding the expected commandLength did not match the actual encoded (a serious error with our own encoding process)", pdu.getCommandLength(), buffer.readableBytes());
@Override public String toString() { StringBuilder buffer = new StringBuilder(65 + 300 + (getOptionalParameterCount()*20)); buffer.append(this.name); buffer.append(": 0x"); buffer.append(HexUtil.toHexString(getCommandLength())); buffer.append(" 0x"); buffer.append(HexUtil.toHexString(this.commandId)); buffer.append(HexUtil.toHexString(this.commandStatus)); buffer.append(" 0x"); buffer.append(HexUtil.toHexString(getSequenceNumber())); this.appendBodyToString(buffer); this.appendOptionalParameterToString(buffer); buffer.append(")");
/** * Sets an optional parameter by checking if the tag already exists in our * list of optional parameters. If it already exists, will replace the old * value with the new value. * @param tlv The TLV to add/set * @return Null if no TLV was replaced, or the TLV replaced. */ public Tlv setOptionalParameter(Tlv tlv) { // does this parameter already exist? int i = this.findOptionalParameter(tlv.getTag()); if (i < 0) { // parameter does not yet exist, add it, not replaced this.addOptionalParameter(tlv); return null; } else { // this parameter already exists, replace it, return old return this.optionalParameters.set(i, tlv); } }
public void readOptionalParameters(ChannelBuffer buffer, PduTranscoderContext context) throws UnrecoverablePduException, RecoverablePduException { // if there is any data left, it's part of an optional parameter while (buffer.readableBytes() > 0) { Tlv tlv = ChannelBufferUtil.readTlv(buffer); if (tlv.getTagName() == null) { tlv.setTagName(context.lookupTlvTagName(tlv.getTag())); } this.addOptionalParameter(tlv); } }
PduResponse response = (PduResponse)pdu; if (response.getResultMessage() == null) { response.setResultMessage(context.lookupResultMessage(pdu.getCommandStatus())); if (!pdu.hasCommandLengthCalculated()) { pdu.calculateAndSetCommandLength(); ChannelBuffer buffer = new BigEndianHeapChannelBuffer(pdu.getCommandLength()); buffer.writeInt(pdu.getCommandLength()); buffer.writeInt(pdu.getCommandId()); buffer.writeInt(pdu.getCommandStatus()); buffer.writeInt(pdu.getSequenceNumber()); pdu.writeBody(buffer); pdu.writeOptionalParameters(buffer, context); if (buffer.readableBytes() != pdu.getCommandLength()) { throw new NotEnoughDataInBufferException("During PDU encoding the expected commandLength did not match the actual encoded (a serious error with our own encoding process)", pdu.getCommandLength(), buffer.readableBytes());
@Override public String toString() { StringBuilder buffer = new StringBuilder(65 + 300 + (getOptionalParameterCount()*20)); buffer.append(this.name); buffer.append(": 0x"); buffer.append(HexUtil.toHexString(getCommandLength())); buffer.append(" 0x"); buffer.append(HexUtil.toHexString(this.commandId)); buffer.append(HexUtil.toHexString(this.commandStatus)); buffer.append(" 0x"); buffer.append(HexUtil.toHexString(getSequenceNumber())); this.appendBodyToString(buffer); this.appendOptionalParameterToString(buffer); buffer.append(")");
/** * Calculates and sets the commandLength for the PDU based on all currently * set values and optional parameters. * @return The calculated PDU command length */ public int calculateAndSetCommandLength() { int len = SmppConstants.PDU_HEADER_LENGTH + this.calculateByteSizeOfBody() + this.calculateByteSizeOfOptionalParameters(); this.setCommandLength(len); return len; }
/** * Sets an optional parameter by checking if the tag already exists in our * list of optional parameters. If it already exists, will replace the old * value with the new value. * @param tlv The TLV to add/set * @return Null if no TLV was replaced, or the TLV replaced. */ public Tlv setOptionalParameter(Tlv tlv) { // does this parameter already exist? int i = this.findOptionalParameter(tlv.getTag()); if (i < 0) { // parameter does not yet exist, add it, not replaced this.addOptionalParameter(tlv); return null; } else { // this parameter already exists, replace it, return old return this.optionalParameters.set(i, tlv); } }
/** * Checks if an optional parameter by tag exists. * @param tag The TLV to search for * @return True if exists, otherwise false */ public boolean hasOptionalParameter(short tag) { return (this.findOptionalParameter(tag) >= 0); }
public void readOptionalParameters(ChannelBuffer buffer, PduTranscoderContext context) throws UnrecoverablePduException, RecoverablePduException { // if there is any data left, it's part of an optional parameter while (buffer.readableBytes() > 0) { Tlv tlv = ChannelBufferUtil.readTlv(buffer); if (tlv.getTagName() == null) { tlv.setTagName(context.lookupTlvTagName(tlv.getTag())); } this.addOptionalParameter(tlv); } }
PduResponse response = (PduResponse)pdu; if (response.getResultMessage() == null) { response.setResultMessage(context.lookupResultMessage(pdu.getCommandStatus())); if (!pdu.hasCommandLengthCalculated()) { pdu.calculateAndSetCommandLength(); ChannelBuffer buffer = new BigEndianHeapChannelBuffer(pdu.getCommandLength()); buffer.writeInt(pdu.getCommandLength()); buffer.writeInt(pdu.getCommandId()); buffer.writeInt(pdu.getCommandStatus()); buffer.writeInt(pdu.getSequenceNumber()); pdu.writeBody(buffer); pdu.writeOptionalParameters(buffer, context); if (buffer.readableBytes() != pdu.getCommandLength()) { throw new NotEnoughDataInBufferException("During PDU encoding the expected commandLength did not match the actual encoded (a serious error with our own encoding process)", pdu.getCommandLength(), buffer.readableBytes());
@Override public String toString() { StringBuilder buffer = new StringBuilder(65 + 300 + (getOptionalParameterCount()*20)); buffer.append(this.name); buffer.append(": 0x"); buffer.append(HexUtil.toHexString(getCommandLength())); buffer.append(" 0x"); buffer.append(HexUtil.toHexString(this.commandId)); buffer.append(HexUtil.toHexString(this.commandStatus)); buffer.append(" 0x"); buffer.append(HexUtil.toHexString(getSequenceNumber())); this.appendBodyToString(buffer); this.appendOptionalParameterToString(buffer); buffer.append(")");
/** * Calculates and sets the commandLength for the PDU based on all currently * set values and optional parameters. * @return The calculated PDU command length */ public int calculateAndSetCommandLength() { int len = SmppConstants.PDU_HEADER_LENGTH + this.calculateByteSizeOfBody() + this.calculateByteSizeOfOptionalParameters(); this.setCommandLength(len); return len; }
/** * Sets an optional parameter by checking if the tag already exists in our * list of optional parameters. If it already exists, will replace the old * value with the new value. * @param tlv The TLV to add/set * @return Null if no TLV was replaced, or the TLV replaced. */ public Tlv setOptionalParameter(Tlv tlv) { // does this parameter already exist? int i = this.findOptionalParameter(tlv.getTag()); if (i < 0) { // parameter does not yet exist, add it, not replaced this.addOptionalParameter(tlv); return null; } else { // this parameter already exists, replace it, return old return this.optionalParameters.set(i, tlv); } }