Class TLVMsg

java.lang.Object
org.jpos.tlv.TLVMsg
All Implemented Interfaces:
Loggeable

public class TLVMsg extends Object implements Loggeable
A single TLV (Tag-Length-Value) message element.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
    TLVMsg(int tag, byte[] value)
    Deprecated.
    In most cases, a message is created to attach it to the list.
    protected
    TLVMsg(int tag, byte[] value, int tagSize, int lengthSize)
    Constructs a TLV message using explicit tag and length sizes.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    dump(PrintStream p, String indent)
    Dumps a human-readable representation of this object to the print stream.
    byte[]
    Value up to 127 can be encoded in single byte and multiple bytes are required for length bigger than 127
    Returns the TLV value as a hexadecimal string.
    int
    Returns the TLV tag identifier.
    byte[]
    Returns the encoded TLV message bytes.
    byte[]
    Returns the TLV value bytes.
     

    Methods inherited from class Object

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

    Methods inherited from interface Loggeable

    dump
    Modifier and Type
    Method
    Description
    default void
    Dumps a representation of this object using the specified renderer type.
  • Constructor Details

    • TLVMsg

      @Deprecated public TLVMsg(int tag, byte[] value) throws IllegalArgumentException
      Deprecated.
      In most cases, a message is created to attach it to the list.
      It can be done by:
        TLVList tl = ...;
        tl.append(tag, value);
      
      If for some reason this is not possible then a message can be created:
        TLVList tl = TLVListBuilder.createInstance().build(); // or just new TLVList();
        tl.append(tag, value);
        TLVMsg tm = tl.find(tag);
      
      The intention is to not promote the use of TLVMsg outside. Due to the lack of compatibility of various TLV types at TLVList.append(TLVMsg)
      Constructs a TLV message from tag and value.
      Parameters:
      tag - id
      value - tag value
      Throws:
      IllegalArgumentException
    • TLVMsg

      protected TLVMsg(int tag, byte[] value, int tagSize, int lengthSize) throws IllegalArgumentException
      Constructs a TLV message using explicit tag and length sizes.
      Parameters:
      tag - the TLV tag identifier
      value - the TLV value bytes
      tagSize - fixed tag size, or 0 for auto-detection
      lengthSize - fixed length size, or 0 for auto-detection
      Throws:
      IllegalArgumentException - if the supplied tag or value is invalid
  • Method Details

    • getTag

      public int getTag()
      Returns the TLV tag identifier.
      Returns:
      tag
    • getValue

      public byte[] getValue()
      Returns the TLV value bytes.
      Returns:
      tag value
    • getTLV

      public byte[] getTLV()
      Returns the encoded TLV message bytes.
      Returns:
      tag + length + value of the TLV message
    • getL

      public byte[] getL()
      Value up to 127 can be encoded in single byte and multiple bytes are required for length bigger than 127
      Returns:
      encoded length
    • getStringValue

      Returns the TLV value as a hexadecimal string.
      Returns:
      value
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • dump

      public void dump(PrintStream p, String indent)
      Description copied from interface: Loggeable
      Dumps a human-readable representation of this object to the print stream.
      Specified by:
      dump in interface Loggeable
      Parameters:
      p - the output stream
      indent - indentation prefix