Class Conversion
The methods names follow a naming rule:
<source type>[source endianness][source bit ordering]To<destination type>[destination endianness][destination bit ordering]
Source/destination type fields is one of the following:
- binary: an array of booleans
- byte or byteArray
- int or intArray
- long or longArray
- hex: a String containing hexadecimal digits (lowercase in destination)
- hexDigit: a Char containing a hexadecimal digit (lowercase in destination)
- uuid
Endianness field: little endian is the default, in this case the field is absent. In case of
big endian, the field is "Be".
Bit ordering: Lsb0 is the default, in this case the field
is absent. In case of Msb0, the field is "Msb0".
Example: intBeMsb0ToHex convert an int with big endian byte order and Msb0 bit order into its hexadecimal string representation
Most of the methods provide only default encoding for destination, this limits the number of ways to do one thing. Unless you are dealing with data from/to outside of the JVM platform, you should not need to use "Be" and "Msb0" methods.
Development status: work on going, only a part of the little endian, Lsb0 methods implemented so far.
- Since:
- 3.2
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic charbinaryBeMsb0ToHexDigit(boolean[] src) Converts the first 4 bits of a binary (represented as boolean array) in big endian Msb0 bit ordering to a hexadecimal digit.static charbinaryBeMsb0ToHexDigit(boolean[] src, int srcPos) Converts a binary (represented as boolean array) in big endian Msb0 bit ordering to a hexadecimal digit.static bytebinaryToByte(boolean[] src, int srcPos, byte dstInit, int dstPos, int nBools) Converts binary (represented as boolean array) into a byte using the default (little endian, Lsb0) byte and bit ordering.static charbinaryToHexDigit(boolean[] src) Converts binary (represented as boolean array) to a hexadecimal digit using the default (Lsb0) bit ordering.static charbinaryToHexDigit(boolean[] src, int srcPos) Converts binary (represented as boolean array) to a hexadecimal digit using the default (Lsb0) bit ordering.static charbinaryToHexDigitMsb0_4bits(boolean[] src) Converts binary (represented as boolean array) to a hexadecimal digit using the Msb0 bit ordering.static charbinaryToHexDigitMsb0_4bits(boolean[] src, int srcPos) Converts binary (represented as boolean array) to a hexadecimal digit using the Msb0 bit ordering.static intbinaryToInt(boolean[] src, int srcPos, int dstInit, int dstPos, int nBools) Converts binary (represented as boolean array) into an int using the default (little endian, Lsb0) byte and bit ordering.static longbinaryToLong(boolean[] src, int srcPos, long dstInit, int dstPos, int nBools) Converts binary (represented as boolean array) into a long using the default (little endian, Lsb0) byte and bit ordering.static shortbinaryToShort(boolean[] src, int srcPos, short dstInit, int dstPos, int nBools) Converts binary (represented as boolean array) into a short using the default (little endian, Lsb0) byte and bit ordering.static intbyteArrayToInt(byte[] src, int srcPos, int dstInit, int dstPos, int nBytes) Converts an array of byte into an int using the default (little endian, Lsb0) byte and bit ordering.static longbyteArrayToLong(byte[] src, int srcPos, long dstInit, int dstPos, int nBytes) Converts an array of byte into a long using the default (little endian, Lsb0) byte and bit ordering.static shortbyteArrayToShort(byte[] src, int srcPos, short dstInit, int dstPos, int nBytes) Converts an array of byte into a short using the default (little endian, Lsb0) byte and bit ordering.static UUIDbyteArrayToUuid(byte[] src, int srcPos) Converts bytes from an array into a UUID using the default (little endian, Lsb0) byte and bit ordering.static boolean[]byteToBinary(byte src, int srcPos, boolean[] dst, int dstPos, int nBools) Converts a byte into an array of boolean using the default (little endian, Lsb0) byte and bit ordering.static StringConverts a byte into an array of Char using the default (little endian, Lsb0) byte and bit ordering.static boolean[]hexDigitMsb0ToBinary(char hexDigit) Converts a hexadecimal digit into binary (represented as boolean array) using the Msb0 bit ordering.static inthexDigitMsb0ToInt(char hexDigit) Converts a hexadecimal digit into an int using the Msb0 bit ordering.static boolean[]hexDigitToBinary(char hexDigit) Converts a hexadecimal digit into binary (represented as boolean array) using the default (Lsb0) bit ordering.static inthexDigitToInt(char hexDigit) Converts a hexadecimal digit into an int using the default (Lsb0) bit ordering.static byteConverts an array of Char into a byte using the default (little endian, Lsb0) byte and bit ordering.static intConverts an array of Char into an int using the default (little endian, Lsb0) byte and bit ordering.static longConverts an array of Char into a long using the default (little endian, Lsb0) byte and bit ordering.static shorthexToShort(String src, int srcPos, short dstInit, int dstPos, int nHex) Converts an array of Char into a short using the default (little endian, Lsb0) byte and bit ordering.static longintArrayToLong(int[] src, int srcPos, long dstInit, int dstPos, int nInts) Converts an array of int into a long using the default (little endian, Lsb0) byte and bit ordering.static boolean[]intToBinary(int src, int srcPos, boolean[] dst, int dstPos, int nBools) Converts an int into an array of boolean using the default (little endian, Lsb0) byte and bit ordering.static byte[]intToByteArray(int src, int srcPos, byte[] dst, int dstPos, int nBytes) Converts an int into an array of byte using the default (little endian, Lsb0) byte and bit ordering.static StringConverts an int into an array of Char using the default (little endian, Lsb0) byte and bit ordering.static charintToHexDigit(int nibble) Converts the 4 lsb of an int to a hexadecimal digit.static charintToHexDigitMsb0(int nibble) Converts the 4 lsb of an int to a hexadecimal digit encoded using the Msb0 bit ordering.static short[]intToShortArray(int src, int srcPos, short[] dst, int dstPos, int nShorts) Converts an int into an array of short using the default (little endian, Lsb0) byte and bit ordering.static boolean[]longToBinary(long src, int srcPos, boolean[] dst, int dstPos, int nBools) Converts a long into an array of boolean using the default (little endian, Lsb0) byte and bit ordering.static byte[]longToByteArray(long src, int srcPos, byte[] dst, int dstPos, int nBytes) Converts a long into an array of byte using the default (little endian, Lsb0) byte and bit ordering.static StringConverts a long into an array of Char using the default (little endian, Lsb0) byte and bit ordering.static int[]longToIntArray(long src, int srcPos, int[] dst, int dstPos, int nInts) Converts a long into an array of int using the default (little endian, Lsb0) byte and bit ordering.static short[]longToShortArray(long src, int srcPos, short[] dst, int dstPos, int nShorts) Converts a long into an array of short using the default (little endian, Lsb0) byte and bit ordering.static intshortArrayToInt(short[] src, int srcPos, int dstInit, int dstPos, int nShorts) Converts an array of short into an int using the default (little endian, Lsb0) byte and bit ordering.static longshortArrayToLong(short[] src, int srcPos, long dstInit, int dstPos, int nShorts) Converts an array of short into a long using the default (little endian, Lsb0) byte and bit ordering.static boolean[]shortToBinary(short src, int srcPos, boolean[] dst, int dstPos, int nBools) Converts a short into an array of boolean using the default (little endian, Lsb0) byte and bit ordering.static byte[]shortToByteArray(short src, int srcPos, byte[] dst, int dstPos, int nBytes) Converts a short into an array of byte using the default (little endian, Lsb0) byte and bit ordering.static StringshortToHex(short src, int srcPos, String dstInit, int dstPos, int nHexs) Converts a short into an array of Char using the default (little endian, Lsb0) byte and bit ordering.static byte[]uuidToByteArray(UUID src, byte[] dst, int dstPos, int nBytes) Converts UUID into an array of byte using the default (little endian, Lsb0) byte and bit ordering.
-
Constructor Details
-
Conversion
public Conversion()
-
-
Method Details
-
binaryBeMsb0ToHexDigit
Converts the first 4 bits of a binary (represented as boolean array) in big endian Msb0 bit ordering to a hexadecimal digit.(1, 0, 0, 0) is converted as follow: '8' (1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0) is converted to '4'
- Parameters:
src- the binary to convert- Returns:
- a hexadecimal digit representing the selected bits
- Throws:
IllegalArgumentException- ifsrcis emptyNullPointerException- ifsrcisnull
-
binaryBeMsb0ToHexDigit
Converts a binary (represented as boolean array) in big endian Msb0 bit ordering to a hexadecimal digit.(1, 0, 0, 0) with srcPos = 0 is converted as follow: '8' (1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0) with srcPos = 2 is converted to '5'
- Parameters:
src- the binary to convertsrcPos- the position of the lsb to start the conversion- Returns:
- a hexadecimal digit representing the selected bits
- Throws:
IllegalArgumentException- ifsrcis emptyNullPointerException- ifsrcisnullIndexOutOfBoundsException- ifsrcPosis outside the array.
-
binaryToByte
Converts binary (represented as boolean array) into a byte using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the binary to convertsrcPos- the position insrc, in boolean unit, from where to start the conversiondstInit- initial value of the destination bytedstPos- the position of the lsb, in bits, in the result bytenBools- the number of booleans to convert- Returns:
- a byte containing the selected bits
- Throws:
NullPointerException- ifsrcisnullIllegalArgumentException- ifnBools-1+dstPos >= 8ArrayIndexOutOfBoundsException- ifsrcPos + nBools > src.length
-
binaryToHexDigit
Converts binary (represented as boolean array) to a hexadecimal digit using the default (Lsb0) bit ordering.(1, 0, 0, 0) is converted as follow: '1'
- Parameters:
src- the binary to convert- Returns:
- a hexadecimal digit representing the selected bits
- Throws:
IllegalArgumentException- ifsrcis emptyNullPointerException- ifsrcisnull
-
binaryToHexDigit
Converts binary (represented as boolean array) to a hexadecimal digit using the default (Lsb0) bit ordering.(1, 0, 0, 0) is converted as follow: '1'
- Parameters:
src- the binary to convertsrcPos- the position of the lsb to start the conversion- Returns:
- a hexadecimal digit representing the selected bits
- Throws:
IllegalArgumentException- ifsrcis emptyNullPointerException- ifsrcisnull
-
binaryToHexDigitMsb0_4bits
Converts binary (represented as boolean array) to a hexadecimal digit using the Msb0 bit ordering.(1, 0, 0, 0) is converted as follow: '8'
- Parameters:
src- the binary to convert- Returns:
- a hexadecimal digit representing the selected bits
- Throws:
IllegalArgumentException- ifsrcis empty,src.length < 4orsrc.length > 8NullPointerException- ifsrcisnull
-
binaryToHexDigitMsb0_4bits
Converts binary (represented as boolean array) to a hexadecimal digit using the Msb0 bit ordering.(1, 0, 0, 0) is converted as follow: '8' (1, 0, 0, 1, 1, 0, 1, 0) with srcPos = 3 is converted to 'D'
- Parameters:
src- the binary to convertsrcPos- the position of the lsb to start the conversion- Returns:
- a hexadecimal digit representing the selected bits
- Throws:
IllegalArgumentException- ifsrcis empty,src.length > 8orsrc.length - srcPos < 4NullPointerException- ifsrcisnull
-
binaryToInt
Converts binary (represented as boolean array) into an int using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the binary to convertsrcPos- the position insrc, in boolean unit, from where to start the conversiondstInit- initial value of the destination intdstPos- the position of the lsb, in bits, in the result intnBools- the number of booleans to convert- Returns:
- an int containing the selected bits
- Throws:
NullPointerException- ifsrcisnullIllegalArgumentException- ifnBools-1+dstPos >= 32ArrayIndexOutOfBoundsException- ifsrcPos + nBools > src.length
-
binaryToLong
Converts binary (represented as boolean array) into a long using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the binary to convertsrcPos- the position insrc, in boolean unit, from where to start the conversiondstInit- initial value of the destination longdstPos- the position of the lsb, in bits, in the result longnBools- the number of booleans to convert- Returns:
- a long containing the selected bits
- Throws:
NullPointerException- ifsrcisnullIllegalArgumentException- ifnBools-1+dstPos >= 64ArrayIndexOutOfBoundsException- ifsrcPos + nBools > src.length
-
binaryToShort
Converts binary (represented as boolean array) into a short using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the binary to convertsrcPos- the position insrc, in boolean unit, from where to start the conversiondstInit- initial value of the destination shortdstPos- the position of the lsb, in bits, in the result shortnBools- the number of booleans to convert- Returns:
- a short containing the selected bits
- Throws:
NullPointerException- ifsrcisnullIllegalArgumentException- ifnBools-1+dstPos >= 16ArrayIndexOutOfBoundsException- ifsrcPos + nBools > src.length
-
byteArrayToInt
Converts an array of byte into an int using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the byte array to convertsrcPos- the position insrc, in byte unit, from where to start the conversiondstInit- initial value of the destination intdstPos- the position of the lsb, in bits, in the result intnBytes- the number of bytes to convert- Returns:
- an int containing the selected bits
- Throws:
NullPointerException- ifsrcisnullIllegalArgumentException- if(nBytes-1)*8+dstPos >= 32ArrayIndexOutOfBoundsException- ifsrcPos + nBytes > src.length
-
byteArrayToLong
Converts an array of byte into a long using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the byte array to convertsrcPos- the position insrc, in byte unit, from where to start the conversiondstInit- initial value of the destination longdstPos- the position of the lsb, in bits, in the result longnBytes- the number of bytes to convert- Returns:
- a long containing the selected bits
- Throws:
NullPointerException- ifsrcisnullIllegalArgumentException- if(nBytes-1)*8+dstPos >= 64ArrayIndexOutOfBoundsException- ifsrcPos + nBytes > src.length
-
byteArrayToShort
Converts an array of byte into a short using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the byte array to convertsrcPos- the position insrc, in byte unit, from where to start the conversiondstInit- initial value of the destination shortdstPos- the position of the lsb, in bits, in the result shortnBytes- the number of bytes to convert- Returns:
- a short containing the selected bits
- Throws:
NullPointerException- ifsrcisnullIllegalArgumentException- if(nBytes-1)*8+dstPos >= 16ArrayIndexOutOfBoundsException- ifsrcPos + nBytes > src.length
-
byteArrayToUuid
Converts bytes from an array into a UUID using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the byte array to convertsrcPos- the position insrcwhere to copy the result from- Returns:
- a UUID
- Throws:
NullPointerException- ifsrcisnullIllegalArgumentException- if array does not contain at least 16 bytes beginning withsrcPos
-
byteToBinary
Converts a byte into an array of boolean using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the byte to convertsrcPos- the position insrc, in bits, from where to start the conversiondst- the destination arraydstPos- the position indstwhere to copy the resultnBools- the number of booleans to copy todst, must be smaller or equal to the width of the input (from srcPos to msb)- Returns:
dst- Throws:
NullPointerException- ifdstisnullIllegalArgumentException- ifnBools-1+srcPos >= 8ArrayIndexOutOfBoundsException- ifdstPos + nBools > dst.length
-
byteToHex
Converts a byte into an array of Char using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the byte to convertsrcPos- the position insrc, in bits, from where to start the conversiondstInit- the initial value for the result StringdstPos- the position indstwhere to copy the resultnHexs- the number of Chars to copy todst, must be smaller or equal to the width of the input (from srcPos to msb)- Returns:
dst- Throws:
IllegalArgumentException- if(nHexs-1)*4+srcPos >= 8StringIndexOutOfBoundsException- ifdst.init.length() < dstPos
-
hexDigitMsb0ToBinary
Converts a hexadecimal digit into binary (represented as boolean array) using the Msb0 bit ordering.'1' is converted as follow: (0, 0, 0, 1)
- Parameters:
hexDigit- the hexadecimal digit to convert- Returns:
- a boolean array with the binary representation of
hexDigit - Throws:
IllegalArgumentException- ifhexDigitis not a hexadecimal digit
-
hexDigitMsb0ToInt
Converts a hexadecimal digit into an int using the Msb0 bit ordering.'1' is converted to 8
- Parameters:
hexDigit- the hexadecimal digit to convert- Returns:
- an int equals to
hexDigit - Throws:
IllegalArgumentException- ifhexDigitis not a hexadecimal digit
-
hexDigitToBinary
Converts a hexadecimal digit into binary (represented as boolean array) using the default (Lsb0) bit ordering.'1' is converted as follow: (1, 0, 0, 0)
- Parameters:
hexDigit- the hexadecimal digit to convert- Returns:
- a boolean array with the binary representation of
hexDigit - Throws:
IllegalArgumentException- ifhexDigitis not a hexadecimal digit
-
hexDigitToInt
Converts a hexadecimal digit into an int using the default (Lsb0) bit ordering.'1' is converted to 1
- Parameters:
hexDigit- the hexadecimal digit to convert- Returns:
- an int equals to
hexDigit - Throws:
IllegalArgumentException- ifhexDigitis not a hexadecimal digit
-
hexToByte
Converts an array of Char into a byte using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the hexadecimal string to convertsrcPos- the position insrc, in Char unit, from where to start the conversiondstInit- initial value of the destination bytedstPos- the position of the lsb, in bits, in the result bytenHex- the number of Chars to convert- Returns:
- a byte containing the selected bits
- Throws:
IllegalArgumentException- if(nHexs-1)*4+dstPos >= 8
-
hexToInt
Converts an array of Char into an int using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the hexadecimal string to convertsrcPos- the position insrc, in Char unit, from where to start the conversiondstInit- initial value of the destination intdstPos- the position of the lsb, in bits, in the result intnHex- the number of Chars to convert- Returns:
- an int containing the selected bits
- Throws:
IllegalArgumentException- if(nHexs-1)*4+dstPos >= 32
-
hexToLong
Converts an array of Char into a long using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the hexadecimal string to convertsrcPos- the position insrc, in Char unit, from where to start the conversiondstInit- initial value of the destination longdstPos- the position of the lsb, in bits, in the result longnHex- the number of Chars to convert- Returns:
- a long containing the selected bits
- Throws:
IllegalArgumentException- if(nHexs-1)*4+dstPos >= 64
-
hexToShort
Converts an array of Char into a short using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the hexadecimal string to convertsrcPos- the position insrc, in Char unit, from where to start the conversiondstInit- initial value of the destination shortdstPos- the position of the lsb, in bits, in the result shortnHex- the number of Chars to convert- Returns:
- a short containing the selected bits
- Throws:
IllegalArgumentException- if(nHexs-1)*4+dstPos >= 16
-
intArrayToLong
Converts an array of int into a long using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the int array to convertsrcPos- the position insrc, in int unit, from where to start the conversiondstInit- initial value of the destination longdstPos- the position of the lsb, in bits, in the result longnInts- the number of ints to convert- Returns:
- a long containing the selected bits
- Throws:
IllegalArgumentException- if(nInts-1)*32+dstPos >= 64NullPointerException- ifsrcisnullArrayIndexOutOfBoundsException- ifsrcPos + nInts > src.length
-
intToBinary
Converts an int into an array of boolean using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the int to convertsrcPos- the position insrc, in bits, from where to start the conversiondst- the destination arraydstPos- the position indstwhere to copy the resultnBools- the number of booleans to copy todst, must be smaller or equal to the width of the input (from srcPos to msb)- Returns:
dst- Throws:
NullPointerException- ifdstisnullIllegalArgumentException- ifnBools-1+srcPos >= 32ArrayIndexOutOfBoundsException- ifdstPos + nBools > dst.length
-
intToByteArray
Converts an int into an array of byte using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the int to convertsrcPos- the position insrc, in bits, from where to start the conversiondst- the destination arraydstPos- the position indstwhere to copy the resultnBytes- the number of bytes to copy todst, must be smaller or equal to the width of the input (from srcPos to msb)- Returns:
dst- Throws:
NullPointerException- ifdstisnullIllegalArgumentException- if(nBytes-1)*8+srcPos >= 32ArrayIndexOutOfBoundsException- ifdstPos + nBytes > dst.length
-
intToHex
Converts an int into an array of Char using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the int to convertsrcPos- the position insrc, in bits, from where to start the conversiondstInit- the initial value for the result StringdstPos- the position indstwhere to copy the resultnHexs- the number of Chars to copy todst, must be smaller or equal to the width of the input (from srcPos to msb)- Returns:
dst- Throws:
IllegalArgumentException- if(nHexs-1)*4+srcPos >= 32StringIndexOutOfBoundsException- ifdst.init.length() < dstPos
-
intToHexDigit
Converts the 4 lsb of an int to a hexadecimal digit.0 returns '0'
1 returns '1'
10 returns 'A' and so on...
- Parameters:
nibble- the 4 bits to convert- Returns:
- a hexadecimal digit representing the 4 lsb of
nibble - Throws:
IllegalArgumentException- ifnibble < 0ornibble > 15
-
intToHexDigitMsb0
Converts the 4 lsb of an int to a hexadecimal digit encoded using the Msb0 bit ordering.0 returns '0'
1 returns '8'
10 returns '5' and so on...
- Parameters:
nibble- the 4 bits to convert- Returns:
- a hexadecimal digit representing the 4 lsb of
nibble - Throws:
IllegalArgumentException- ifnibble < 0ornibble > 15
-
intToShortArray
Converts an int into an array of short using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the int to convertsrcPos- the position insrc, in bits, from where to start the conversiondst- the destination arraydstPos- the position indstwhere to copy the resultnShorts- the number of shorts to copy todst, must be smaller or equal to the width of the input (from srcPos to msb)- Returns:
dst- Throws:
NullPointerException- ifdstisnullIllegalArgumentException- if(nShorts-1)*16+srcPos >= 32ArrayIndexOutOfBoundsException- ifdstPos + nShorts > dst.length
-
longToBinary
Converts a long into an array of boolean using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the long to convertsrcPos- the position insrc, in bits, from where to start the conversiondst- the destination arraydstPos- the position indstwhere to copy the resultnBools- the number of booleans to copy todst, must be smaller or equal to the width of the input (from srcPos to msb)- Returns:
dst- Throws:
NullPointerException- ifdstisnullIllegalArgumentException- ifnBools-1+srcPos >= 64ArrayIndexOutOfBoundsException- ifdstPos + nBools > dst.length
-
longToByteArray
Converts a long into an array of byte using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the long to convertsrcPos- the position insrc, in bits, from where to start the conversiondst- the destination arraydstPos- the position indstwhere to copy the resultnBytes- the number of bytes to copy todst, must be smaller or equal to the width of the input (from srcPos to msb)- Returns:
dst- Throws:
NullPointerException- ifdstisnullIllegalArgumentException- if(nBytes-1)*8+srcPos >= 64ArrayIndexOutOfBoundsException- ifdstPos + nBytes > dst.length
-
longToHex
Converts a long into an array of Char using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the long to convertsrcPos- the position insrc, in bits, from where to start the conversiondstInit- the initial value for the result StringdstPos- the position indstwhere to copy the resultnHexs- the number of Chars to copy todst, must be smaller or equal to the width of the input (from srcPos to msb)- Returns:
dst- Throws:
IllegalArgumentException- if(nHexs-1)*4+srcPos >= 64StringIndexOutOfBoundsException- ifdst.init.length() < dstPos
-
longToIntArray
Converts a long into an array of int using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the long to convertsrcPos- the position insrc, in bits, from where to start the conversiondst- the destination arraydstPos- the position indstwhere to copy the resultnInts- the number of ints to copy todst, must be smaller or equal to the width of the input (from srcPos to msb)- Returns:
dst- Throws:
NullPointerException- ifdstisnullandnInts > 0IllegalArgumentException- if(nInts-1)*32+srcPos >= 64ArrayIndexOutOfBoundsException- ifdstPos + nInts > dst.length
-
longToShortArray
Converts a long into an array of short using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the long to convertsrcPos- the position insrc, in bits, from where to start the conversiondst- the destination arraydstPos- the position indstwhere to copy the resultnShorts- the number of shorts to copy todst, must be smaller or equal to the width of the input (from srcPos to msb)- Returns:
dst- Throws:
NullPointerException- ifdstisnullIllegalArgumentException- if(nShorts-1)*16+srcPos >= 64ArrayIndexOutOfBoundsException- ifdstPos + nShorts > dst.length
-
shortArrayToInt
Converts an array of short into an int using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the short array to convertsrcPos- the position insrc, in short unit, from where to start the conversiondstInit- initial value of the destination intdstPos- the position of the lsb, in bits, in the result intnShorts- the number of shorts to convert- Returns:
- an int containing the selected bits
- Throws:
NullPointerException- ifsrcisnullIllegalArgumentException- if(nShorts-1)*16+dstPos >= 32ArrayIndexOutOfBoundsException- ifsrcPos + nShorts > src.length
-
shortArrayToLong
Converts an array of short into a long using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the short array to convertsrcPos- the position insrc, in short unit, from where to start the conversiondstInit- initial value of the destination longdstPos- the position of the lsb, in bits, in the result longnShorts- the number of shorts to convert- Returns:
- a long containing the selected bits
- Throws:
NullPointerException- ifsrcisnullIllegalArgumentException- if(nShorts-1)*16+dstPos >= 64ArrayIndexOutOfBoundsException- ifsrcPos + nShorts > src.length
-
shortToBinary
Converts a short into an array of boolean using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the short to convertsrcPos- the position insrc, in bits, from where to start the conversiondst- the destination arraydstPos- the position indstwhere to copy the resultnBools- the number of booleans to copy todst, must be smaller or equal to the width of the input (from srcPos to msb)- Returns:
dst- Throws:
NullPointerException- ifdstisnullIllegalArgumentException- ifnBools-1+srcPos >= 16ArrayIndexOutOfBoundsException- ifdstPos + nBools > dst.length
-
shortToByteArray
Converts a short into an array of byte using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the short to convertsrcPos- the position insrc, in bits, from where to start the conversiondst- the destination arraydstPos- the position indstwhere to copy the resultnBytes- the number of bytes to copy todst, must be smaller or equal to the width of the input (from srcPos to msb)- Returns:
dst- Throws:
NullPointerException- ifdstisnullIllegalArgumentException- if(nBytes-1)*8+srcPos >= 16ArrayIndexOutOfBoundsException- ifdstPos + nBytes > dst.length
-
shortToHex
Converts a short into an array of Char using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the short to convertsrcPos- the position insrc, in bits, from where to start the conversiondstInit- the initial value for the result StringdstPos- the position indstwhere to copy the resultnHexs- the number of Chars to copy todst, must be smaller or equal to the width of the input (from srcPos to msb)- Returns:
dst- Throws:
IllegalArgumentException- if(nHexs-1)*4+srcPos >= 16StringIndexOutOfBoundsException- ifdst.init.length() < dstPos
-
uuidToByteArray
Converts UUID into an array of byte using the default (little endian, Lsb0) byte and bit ordering.- Parameters:
src- the UUID to convertdst- the destination arraydstPos- the position indstwhere to copy the resultnBytes- the number of bytes to copy todst, must be smaller or equal to the width of the input (from srcPos to msb)- Returns:
dst- Throws:
NullPointerException- ifdstisnullIllegalArgumentException- ifnBytes > 16ArrayIndexOutOfBoundsException- ifdstPos + nBytes > dst.length
-