Package com.reve.utils.bytearray
Class TLVUtils
java.lang.Object
com.reve.utils.bytearray.TLVUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intappendAttribute(byte[] data, int index, int type, boolean value) Append the boolean value using 1 byte into the given byte array at given index.static intappendAttribute(byte[] data, int index, int type, byte value) Append the byte value using 1 byte into the given byte array at given index.static intappendAttribute(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 intappendAttribute(byte[] data, int index, int type, double value, int numberOfBytes) Append the double value usingnumberOfBytesbytes into the given byte array at given index.static intappendAttribute(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 intappendAttribute(byte[] data, int index, int type, ByteArray value) Append the byte array value into the given byte array at given index.static intappendAttribute(byte[] data, int index, int type, String value) Append the String value into the given byte array at given index.static voidtest()
-
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 addedtype- 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 addedtype- 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 addedtype- Type of TLV format.value- This value will be appended. Long value will be appended usingnumberOfBytesbyte in little-endiannumberOfBytes- 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 usingnumberOfBytesbytes 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 addedtype- Type of TLV format.value- This value will be appended. Double value will be appended usingnumberOfBytesbyte in little-endiannumberOfBytes- Defines the number of bytes required to put the value into byte array.- Returns:
- the new index after the value has been appended.
-
appendAttribute
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 addedtype- 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 addedtype- Type of TLV format.value- This value will be appended.offset- starting index of the value byte arraylength- length of value byte array to be appended into data byte array- Returns:
- the new index after the value has been appended.
-
appendAttribute
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 addedtype- 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()
-