Class TLVUtils

java.lang.Object
com.reve.utils.bytearray.TLVUtils

public class TLVUtils extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    appendAttribute(byte[] data, int index, int type, boolean value)
    Append the boolean value using 1 byte into the given byte array at given index.
    static int
    appendAttribute(byte[] data, int index, int type, byte value)
    Append the byte value using 1 byte into the given byte array at given index.
    static int
    appendAttribute(byte[] data, int index, int type, byte[] value, int offset, int length)
    Append the byte array value into the given byte array at given index.
    static int
    appendAttribute(byte[] data, int index, int type, double value, int numberOfBytes)
    Append the double value using numberOfBytes bytes into the given byte array at given index.
    static int
    appendAttribute(byte[] data, int index, int type, long value, int numberOfBytes)
    Append the long value using given number of bytes into the given byte array at given index.
    static int
    appendAttribute(byte[] data, int index, int type, ByteArray value)
    Append the byte array value into the given byte array at given index.
    static int
    appendAttribute(byte[] data, int index, int type, String value)
    Append the String value into the given byte array at given index.
    static void
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TLVUtils

      public TLVUtils()
  • Method Details

    • appendAttribute

      public static int appendAttribute(byte[] data, int index, int type, boolean value)
      Append the boolean value using 1 byte into the given byte array at given index.
      Parameters:
      data - where value will be appended.
      index - starting index of the byte array where value will be added
      type - Type of TLV format.
      value - This value will be appended. If this is true, then byte value 1 will be appended, else if this is false, byte value 0 will be appended.
      Returns:
      the new index after the value has been appended.
    • appendAttribute

      public static int appendAttribute(byte[] data, int index, int type, byte value)
      Append the byte value using 1 byte into the given byte array at given index.
      Parameters:
      data - where value will be appended.
      index - starting index of the byte array where value will be added
      type - Type of TLV format.
      value - This value will be appended. Byte value will be appended using 1 byte.
      Returns:
      the new index after the value has been appended.
    • appendAttribute

      public static int appendAttribute(byte[] data, int index, int type, long value, int numberOfBytes)
      Append the long value using given number of bytes into the given byte array at given index.
      Parameters:
      data - where value will be appended.
      index - starting index of the byte array where value will be added
      type - Type of TLV format.
      value - This value will be appended. Long value will be appended using numberOfBytes byte in little-endian
      numberOfBytes - Defines the number of bytes required to put the value into byte array.
      Returns:
      the new index after the value has been appended.
    • appendAttribute

      public static int appendAttribute(byte[] data, int index, int type, double value, int numberOfBytes)
      Append the double value using numberOfBytes bytes into the given byte array at given index.
      Parameters:
      data - where value will be appended.
      index - starting index of the byte array where value will be added
      type - Type of TLV format.
      value - This value will be appended. Double value will be appended using numberOfBytes byte in little-endian
      numberOfBytes - Defines the number of bytes required to put the value into byte array.
      Returns:
      the new index after the value has been appended.
    • appendAttribute

      public static int appendAttribute(byte[] data, int index, int type, String value)
      Append the String value into the given byte array at given index.
      Parameters:
      data - where value will be appended.
      index - starting index of the byte array where value will be added
      type - Type of TLV format.
      value - This value will be appended.
      Returns:
      the new index after the value has been appended.
    • appendAttribute

      public static int appendAttribute(byte[] data, int index, int type, byte[] value, int offset, int length)
      Append the byte array value into the given byte array at given index.
      Parameters:
      data - where value will be appended.
      index - starting index of the byte array where value will be added
      type - Type of TLV format.
      value - This value will be appended.
      offset - starting index of the value byte array
      length - length of value byte array to be appended into data byte array
      Returns:
      the new index after the value has been appended.
    • appendAttribute

      public static int appendAttribute(byte[] data, int index, int type, ByteArray value)
      Append the byte array value into the given byte array at given index.
      Parameters:
      data - where value will be appended.
      index - starting index of the byte array where value will be added
      type - Type of TLV format.
      value - This value will be appended.
      Returns:
      the new index after the value has been appended.
    • test

      public static void test()