Enum Class WffBinaryMessageUtil

java.lang.Object
java.lang.Enum<WffBinaryMessageUtil>
com.webfirmframework.wffweb.util.WffBinaryMessageUtil
All Implemented Interfaces:
Serializable, Comparable<WffBinaryMessageUtil>, Constable

public enum WffBinaryMessageUtil extends Enum<WffBinaryMessageUtil>
  • Enum Constant Details

    • 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 Details

    • values

      public static WffBinaryMessageUtil[] 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

      public static WffBinaryMessageUtil valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • parse

      public 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(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
    • 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