Class IntegerUtil


  • public class IntegerUtil
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      IntegerUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte firstByte​(int v)
      fetch the first byte
      static int fromBDBytes​(byte[] bytes)
      convert into its integer representation
      static int setByte​(int v, byte bv, int pos)
      set a specified position byte to another value to return a fresh integer
      static int shiftLeftFromSpecifiedPosition​(int v, int pos, int count)
      shift the byte left from the specified position
      static byte[] toBDBytes​(int v)
      convert integer to its byte array format
      • Methods inherited from class java.lang.Object

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

      • IntegerUtil

        public IntegerUtil()
    • Method Detail

      • toBDBytes

        public static byte[] toBDBytes​(int v)
        convert integer to its byte array format
        Parameters:
        v - an input integer value
        Returns:
        the big endian byte array representation
      • fromBDBytes

        public static int fromBDBytes​(byte[] bytes)
        convert into its integer representation
        Parameters:
        bytes - the big endian integer's byte array
        Returns:
        a integer corresponding to input bytes
      • setByte

        public static int setByte​(int v,
                                  byte bv,
                                  int pos)
        set a specified position byte to another value to return a fresh integer
        Parameters:
        v - the input integer value
        bv - the byte value to replace
        pos - the position of an 8 byte array to replace
        Returns:
        a fresh integer after a specified position byte been replaced
      • shiftLeftFromSpecifiedPosition

        public static int shiftLeftFromSpecifiedPosition​(int v,
                                                         int pos,
                                                         int count)
        shift the byte left from the specified position
        Parameters:
        v - a integer value
        pos - the position from which to shift byte values left
        count - the shifting numbers
        Returns:
        a fresh integer value
      • firstByte

        public static byte firstByte​(int v)
        fetch the first byte
        Parameters:
        v - an input integer
        Returns:
        the first byte of the big endian representation