Package org.smpp.pdu.tlv

Examples of org.smpp.pdu.tlv.TLV


    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);
    }
  }
View Full Code Here


   * @see TLV
   */
  private ByteBuffer getOptionalBody(Vector optionalParameters) throws ValueNotSetException {
    ByteBuffer optBody = new ByteBuffer();
    int size = optionalParameters.size();
    TLV tlv = null;
    for (int i = 0; i < size; i++) {
      tlv = (TLV) optionalParameters.get(i);
      if ((tlv != null) && tlv.hasValue()) {
        optBody.appendBuffer(tlv.getData());
      }
    }
    return optBody;
  }
View Full Code Here

   * @see #registerExtraOptional(TLV)
   * @see TLV
   */
  private TLV findOptional(Vector optionalParameters, short tag) {
    int size = optionalParameters.size();
    TLV tlv = null;
    for (int i = 0; i < size; i++) {
      tlv = (TLV) optionalParameters.get(i);
      if (tlv != null) {
        if (tlv.getTag() == tag) {
          return tlv;
        }
      }
    }
    return null;
View Full Code Here

   * new tlv provided as a parameter. If the tlv doesn't exist in the list,
   * adds it to the list.
   */
  private void replaceExtraOptional(TLV tlv) {
    int size = extraOptionalParameters.size();
    TLV existing = null;
    short tlvTag = tlv.getTag();
    for (int i = 0; i < size; i++) {
      existing = (TLV) extraOptionalParameters.get(i);
      if ((existing != null) && (existing.getTag() == tlvTag)) {
        extraOptionalParameters.set(i, tlv);
        return;
      }
    }
    registerExtraOptional(tlv); // the optional param wasn't found
View Full Code Here

  /**
   * Creates new generic extra optional parameter with tag and data provided;
   * uses TLVOctets for the parameter.
   */
  public void setExtraOptional(short tag, ByteBuffer data) throws TLVException {
    TLV tlv = new TLVOctets(tag, data);
    setExtraOptional(tlv);
  }
View Full Code Here

  /**
   * Finds and returns extra optional parameter with the provided
   * tag; if not found returns null.
   */
  public TLV getExtraOptional(short tag) {
    TLV tlv = findOptional(extraOptionalParameters, tag);
    return tlv;
  }
View Full Code Here

  protected String debugStringOptional(String label, Vector optionalParameters) {
    String dbgs = "";
    int size = optionalParameters.size();
    if (size > 0) {
      dbgs += "(" + label + ": ";
      TLV tlv = null;
      for (int i = 0; i < size; i++) {
        tlv = (TLV) optionalParameters.get(i);
        if ((tlv != null) && (tlv.hasValue())) {
          dbgs += tlv.debugString();
          dbgs += " ";
        }
      }
      dbgs += ") ";
    }
View Full Code Here

TOP

Related Classes of org.smpp.pdu.tlv.TLV

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.