Class TLVList

java.lang.Object
org.jpos.tlv.TLVList
All Implemented Interfaces:
Serializable, Loggeable

public class TLVList extends Object implements Serializable, Loggeable
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates instance of TLV engine.
  • Method Summary

    Modifier and Type
    Method
    Description
    append(int tag, byte[] value)
    Append TLVMsg to the TLVList.
    append(int tag, String value)
    Append TLVMsg to the TLVList.
    void
    Append TLVMsg to the TLV list.
    protected TLVMsg
    createTLVMsg(int tag, byte[] value)
    Create TLV message instance.
    void
    deleteByIndex(int index)
    delete the specified TLV from the list using a Zero based index
    void
    deleteByTag(int tag)
    Delete the specified TLV from the list by tag value
    void
    dump(PrintStream p, String indent)
     
     
    find(int tag)
    Searches the list for a specified tag and returns a TLV object.
    int
    findIndex(int tag)
    Searches the list for a specified tag and returns a zero based index for that tag.
    Return the next TLVMsg of same TAG value.
    getString(int tag)
    searches the list for a specified tag and returns a hex String
     
    byte[]
    getValue(int tag)
    searches the list for a specified tag and returns it raw
    protected int
    Read length bytes and return the int value
    boolean
    hasTag(int tag)
    Indicates if TLV measege with passed tag is on list.
    index(int index)
    Returns a TLVMsg instance stored within the TLVList at the given index.
    byte[]
    Pack the TLV message (BER-TLV Encoding).
    void
    unpack(byte[] buf)
    Unpack a message.
    void
    unpack(byte[] buf, int offset)
    Unpack a message with a starting offset.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface Loggeable

    dump
  • Constructor Details

    • TLVList

      public TLVList()
      Creates instance of TLV engine.

      It is a shorter form of:

        TLVListBuilder.createInstance().build();
      
  • Method Details

    • unpack

      public void unpack(byte[] buf) throws IllegalArgumentException
      Unpack a message.
      Parameters:
      buf - raw message
      Throws:
      IllegalArgumentException
    • getTags

      public List<TLVMsg> getTags()
      Returns:
      a list of tags.
    • elements

      Returns:
      an enumeration of the List of tags.
    • unpack

      public void unpack(byte[] buf, int offset) throws IllegalArgumentException, IndexOutOfBoundsException
      Unpack a message with a starting offset.
      Parameters:
      buf - raw message
      offset - the offset
      Throws:
      IndexOutOfBoundsException - if offset exceeds {code buf.length}
      IllegalArgumentException
    • append

      public void append(TLVMsg tlv) throws NullPointerException
      Append TLVMsg to the TLV list.
      Parameters:
      tlv - the TLV message
      Throws:
      NullPointerException - if tlv is null
    • append

      public TLVList append(int tag, byte[] value) throws IllegalArgumentException
      Append TLVMsg to the TLVList.
      Parameters:
      tag - tag id
      value - tag value
      Returns:
      the TLV list instance
      Throws:
      IllegalArgumentException - when contains tag with illegal id
    • append

      public TLVList append(int tag, String value) throws IllegalArgumentException
      Append TLVMsg to the TLVList.
      Parameters:
      tag - id
      value - in hexadecimal character representation
      Returns:
      the TLV list instance
      Throws:
      IllegalArgumentException - when contains tag with illegal id
    • deleteByIndex

      public void deleteByIndex(int index)
      delete the specified TLV from the list using a Zero based index
      Parameters:
      index - number
    • deleteByTag

      public void deleteByTag(int tag)
      Delete the specified TLV from the list by tag value
      Parameters:
      tag - id
    • find

      public TLVMsg find(int tag)
      Searches the list for a specified tag and returns a TLV object.
      Parameters:
      tag - id
      Returns:
      TLV message
    • findIndex

      public int findIndex(int tag)
      Searches the list for a specified tag and returns a zero based index for that tag.
      Parameters:
      tag - tag identifier
      Returns:
      index for a given tag
    • findNextTLV

      Return the next TLVMsg of same TAG value.
      Returns:
      TLV message or null if not found.
      Throws:
      IllegalStateException - when the search has not been initiated
    • index

      public TLVMsg index(int index) throws IndexOutOfBoundsException
      Returns a TLVMsg instance stored within the TLVList at the given index.
      Parameters:
      index - zero based index of TLV message
      Returns:
      TLV message instance
      Throws:
      IndexOutOfBoundsException - if the index is out of range (index invalid input: '<' 0 || index >= size())
    • pack

      public byte[] pack()
      Pack the TLV message (BER-TLV Encoding).
      Returns:
      the packed message
    • createTLVMsg

      protected TLVMsg createTLVMsg(int tag, byte[] value) throws IllegalArgumentException
      Create TLV message instance.
      Parameters:
      tag - tag identifier
      value - the value of tag
      Returns:
      TLV message instance
      Throws:
      IllegalArgumentException - when contains tag with illegal id
      API Note:
      The protected scope is intended to not promote the use of TLVMsg outside.
    • getValueLength

      protected int getValueLength(ByteBuffer buffer) throws IllegalArgumentException
      Read length bytes and return the int value
      Parameters:
      buffer - buffer
      Returns:
      value length
      Throws:
      IllegalArgumentException
    • getString

      public String getString(int tag)
      searches the list for a specified tag and returns a hex String
      Parameters:
      tag - id
      Returns:
      hexString
    • getValue

      public byte[] getValue(int tag)
      searches the list for a specified tag and returns it raw
      Parameters:
      tag - id
      Returns:
      byte[]
    • hasTag

      public boolean hasTag(int tag)
      Indicates if TLV measege with passed tag is on list.
      Parameters:
      tag - tag identifier
      Returns:
      true if tag contains on list, false otherwise
    • dump

      public void dump(PrintStream p, String indent)
      Specified by:
      dump in interface Loggeable