Enum WffBinaryMessageUtil

    • Enum Constant Detail

      • VERSION_1

        public static final WffBinaryMessageUtil 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
        Here, the name length bytes is the length of name bytes and values length bytes is the length of values bytes.
        The values in name-values pair is an array of value, the values is composed as follows
         Value as an array :-
         
        total values length bytes value length bytes value bytes value length bytes value bytes
        Here, total values length bytes = sum of (value length bytes + value bytes + value length bytes + value bytes) no. of bytes.
    • Method Detail

      • values

        public static WffBinaryMessageUtil[] values​()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (WffBinaryMessageUtil c : WffBinaryMessageUtil.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static WffBinaryMessageUtil valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • parse

        public java.util.List<NameValue> parse​(byte[] message)
        Parameters:
        message - the wff binary message bytes
        Returns:
        the list of name value pairs
        Since:
        1.0.0
      • getWffBinaryMessageBytes

        public byte[] getWffBinaryMessageBytes​(java.util.Collection<NameValue> nameValues)
        Parameters:
        nameValues -
        Returns:
        the wff binary message bytes for the given name value pairs
        Since:
        1.0.0
      • getWffBinaryMessageBytes

        public byte[] getWffBinaryMessageBytes​(NameValue... nameValues)
        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
      • 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
      • 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