Package com.webfirmframework.wffweb.util
Enum Class WffBinaryMessageUtil
- All Implemented Interfaces:
Serializable
,Comparable<WffBinaryMessageUtil>
,Constable
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionA wff binary message is a collection of name-value pairs where both name and value can be a binary data. -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
getBytesFromInt
(int value) static int
getIntFromBytes
(byte[] bytes) static int
getIntFromOptimizedBytes
(byte[] bytes) static byte[]
getLastBytesFromInt
(int value, int lastNoOfBytes) static int
getLengthOfOptimizedBytesFromInt
(int value) static long
getLongFrom56bitOptimizedBytes
(byte[] bytes) NB: not fully tested yetstatic long
getLongFromOptimizedBytes
(byte[] bytes) NB: not fully tested yetstatic byte[]
getOptimizedBytesFromDouble
(double value) static byte[]
getOptimizedBytesFromInt
(int value) static byte[]
getOptimizedBytesFromInt56bit
(long value) handles long upto (long) Math.pow(2, 55) - 1static byte[]
getOptimizedBytesFromLong
(long value) byte[]
getWffBinaryMessageBytes
(NameValue... nameValues) byte[]
getWffBinaryMessageBytes
(Collection<NameValue> nameValues) parse
(byte[] message) static WffBinaryMessageUtil
Returns the enum constant of this class with the specified name.static WffBinaryMessageUtil[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
VERSION_1
A wff binary message is a collection of name-value pairs where both name and value can be a binary data. It can have duplicate names.
The wff binary message is composed as follows :-
The first byte represents the maximum number of bytes for name length bytes. The second byte represents the maximum number of bytes for the values length bytes. The remaining bytes represent the name-values pairs.Name values pair name length bytes name bytes values length bytes values bytes
The values in name-values pair is an array of value, the values is composed as followsValue as an array total values length bytes value length bytes value bytes value length bytes value bytes
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
parse
- Parameters:
message
- the wff binary message bytes- Returns:
- the list of name value pairs
- Since:
- 1.0.0
-
getWffBinaryMessageBytes
- Parameters:
nameValues
-- Returns:
- the wff binary message bytes for the given name value pairs
- Since:
- 1.0.0
-
getWffBinaryMessageBytes
- Parameters:
nameValues
-- Returns:
- the wff binary message bytes for the given name value pairs
- Since:
- 2.0.0
-
getIntFromBytes
public static int getIntFromBytes(byte[] bytes) - Parameters:
bytes
- from which the integer value will be obtained- Returns:
- the integer value from the given bytes
- Since:
- 1.0.0
-
getIntFromOptimizedBytes
public static int getIntFromOptimizedBytes(byte[] bytes) - Parameters:
bytes
- the optimized bytes from which the integer value will be obtained- Returns:
- the integer value from the given bytes
- Since:
- 1.1.3
-
getLongFromOptimizedBytes
public static long getLongFromOptimizedBytes(byte[] bytes) NB: not fully tested yet- Parameters:
bytes
- the optimized bytes from which the long value will be obtained- Returns:
- the long value from the given bytes
- Since:
- 3.0.6
-
getLongFrom56bitOptimizedBytes
public static long getLongFrom56bitOptimizedBytes(byte[] bytes) NB: not fully tested yet- Parameters:
bytes
- the optimized bytes from which the long value will be obtained- Returns:
- the long value from the given bytes
- Since:
- 3.0.6
-
getOptimizedBytesFromDouble
public static byte[] getOptimizedBytesFromDouble(double value) - Parameters:
value
-- Returns:
- the bytes for the given double value in the IEEE 754 Standard
- Since:
- 2.0.0
-
getOptimizedBytesFromLong
public static byte[] getOptimizedBytesFromLong(long value) - Parameters:
value
-- Returns:
- the bytes for the given long value
- Since:
- 2.0.0
-
getOptimizedBytesFromInt56bit
public static byte[] getOptimizedBytesFromInt56bit(long value) handles long upto (long) Math.pow(2, 55) - 1- Parameters:
value
-- Returns:
- the bytes for the given long value
- Since:
- 3.0.6
-
getBytesFromInt
public static byte[] getBytesFromInt(int value) - Parameters:
value
- the integer value to be converted to bytes.- Returns:
- the bytes for the corresponding integer given.
- Since:
- 1.0.0
-
getOptimizedBytesFromInt
public static byte[] getOptimizedBytesFromInt(int value) - Parameters:
value
- the integer value to be converted to optimized bytes. Optimized bytes means the minimum bytes required to represent the given integer value.- Returns:
- the bytes for the corresponding integer given.
- Since:
- 1.1.3
-
getLengthOfOptimizedBytesFromInt
public static int getLengthOfOptimizedBytesFromInt(int value) - Parameters:
value
- the integer value to be converted to optimized bytes. Optimized bytes means the minimum bytes required to represent the given integer value.- Returns:
- the array length of the bytes for the corresponding integer given.
- Since:
- 1.1.5
-
getLastBytesFromInt
public static byte[] getLastBytesFromInt(int value, int lastNoOfBytes) - Parameters:
value
- the integer value to be converted to optimized bytes. Optimized bytes means the minimum bytes required to represent the given integer value.lastNoOfBytes
- the last no of bytes to be returned. Expected inputs are 1, 2, 3 or 4.- Returns:
- the bytes for the corresponding integer given.
- Since:
- 1.1.5
-