java.lang.Object
io.github.tonywasher.joceanus.oceanus.convert.OceanusDataConverter

public final class OceanusDataConverter extends Object
Data Conversion utility functions.
  • Field Details

  • Method Details

    • bytesToHexString

      public static String bytesToHexString(byte[] pBytes)
      format a byte array as a hexadecimal string.
      Parameters:
      pBytes - the byte array
      Returns:
      the string
    • longToHexString

      public static String longToHexString(long pValue)
      format a long as a hexadecimal string.
      Parameters:
      pValue - the long value
      Returns:
      the string
    • hexStringToBytes

      public static byte[] hexStringToBytes(String pHexString) throws OceanusException
      parse a byte array from a hexadecimal string.
      Parameters:
      pHexString - the hex string
      Returns:
      the bytes
      Throws:
      OceanusException - on error
    • hexStringToLong

      public static long hexStringToLong(String pHexString) throws OceanusException
      parse a long from a hexadecimal string.
      Parameters:
      pHexString - the hex string
      Returns:
      the bytes
      Throws:
      OceanusException - on error
    • charsToByteArray

      public static byte[] charsToByteArray(char[] pChars) throws OceanusException
      Convert character array to byte array.
      Parameters:
      pChars - the character array
      Returns:
      the byte array
      Throws:
      OceanusException - on error
    • bytesToCharArray

      public static char[] bytesToCharArray(byte[] pBytes) throws OceanusException
      Convert byte array to character array.
      Parameters:
      pBytes - the byte array
      Returns:
      the character array
      Throws:
      OceanusException - on error
    • byteArrayToLong

      public static long byteArrayToLong(byte[] pBytes)
      parse a long from a byte array.
      Parameters:
      pBytes - the eight byte array holding the long
      Returns:
      the long value
    • longToByteArray

      public static byte[] longToByteArray(long pValue)
      build a byte array from a long.
      Parameters:
      pValue - the long value to convert
      Returns:
      the byte array
    • byteArrayToInteger

      public static int byteArrayToInteger(byte[] pBytes)
      parse an integer from a byte array.
      Parameters:
      pBytes - the four byte array holding the integer
      Returns:
      the integer value
    • integerToByteArray

      public static byte[] integerToByteArray(int pValue)
      build a byte array from an integer.
      Parameters:
      pValue - the integer value to convert
      Returns:
      the byte array
    • byteArrayToShort

      public static short byteArrayToShort(byte[] pBytes)
      parse a short from a byte array.
      Parameters:
      pBytes - the four byte array holding the integer
      Returns:
      the short value
    • shortToByteArray

      public static byte[] shortToByteArray(short pValue)
      build a byte array from a short.
      Parameters:
      pValue - the short value to convert
      Returns:
      the byte array
    • byteArrayToString

      public static String byteArrayToString(byte[] pInput)
      get Bytes from String.
      Parameters:
      pInput - the bytes to obtain the string from
      Returns:
      the bytes representing the bytes
    • stringToByteArray

      public static byte[] stringToByteArray(String pInput)
      get Bytes from String.
      Parameters:
      pInput - the string to obtain the bytes from
      Returns:
      the bytes representing the string
    • byteArrayToBase64

      public static String byteArrayToBase64(byte[] pBytes)
      Convert a byte array to a Base64 string.
      Parameters:
      pBytes - the byte array (not null)
      Returns:
      the translated Base64 string (not null)
    • base64ToByteArray

      public static byte[] base64ToByteArray(String pBase64)
      Convert a Base64 string into a byte array.
      Parameters:
      pBase64 - the Base64 string (not null)
      Returns:
      the byte array (not null)