# Class: com.pnfsoftware.jeb.util.io.EndianUtil

Byte array to/from primitives with endianness support.

## Static Method: bigEndianBytesToInt
- parameter: `array`, type: `byte[]`
- return type: `int`

Description: Decode a big\-endian 32\-bit integer at offset 0.
parameter: array: input bytes
return: decoded value

## Static Method: bigEndianBytesToInt
- parameter: `array`, type: `byte[]`
- parameter: `offset`, type: `int`
- return type: `int`

Description: Decode a big\-endian 32\-bit integer.
parameter: array: input bytes
parameter: offset: input offset
return: decoded value

## Static Method: bigEndianBytesToLong
- parameter: `array`, type: `byte[]`
- return type: `long`

Description: Decode a big\-endian 64\-bit integer at offset 0.
parameter: array: input bytes
return: decoded value

## Static Method: bigEndianBytesToLong
- parameter: `array`, type: `byte[]`
- parameter: `offset`, type: `int`
- return type: `long`

Description: Decode a big\-endian 64\-bit integer.
parameter: array: input bytes
parameter: offset: input offset
return: decoded value

## Static Method: bigEndianBytesToShort
- parameter: `array`, type: `byte[]`
- return type: `short`

Description: Decode a big\-endian 16\-bit integer at offset 0.
parameter: array: input bytes
return: decoded value

## Static Method: bigEndianBytesToShort
- parameter: `array`, type: `byte[]`
- parameter: `offset`, type: `int`
- return type: `short`

Description: Decode a big\-endian 16\-bit integer.
parameter: array: input bytes
parameter: offset: input offset
return: decoded value

## Static Method: bytesToInt
- parameter: `array`, type: `byte[]`
- parameter: `offset`, type: `int`
- parameter: `order`, type: `java.nio.ByteOrder`
- return type: `int`

Description: Read 4 bytes and convert it to an integer.
parameter: array: input buffer
parameter: offset: buffer offset
parameter: order: endianness
return: decoded value

## Static Method: bytesToLong
- parameter: `array`, type: `byte[]`
- parameter: `offset`, type: `int`
- parameter: `order`, type: `java.nio.ByteOrder`
- return type: `long`

Description: Read 8 bytes and convert it to a long.
parameter: array: input buffer
parameter: offset: buffer offset
parameter: order: endianness
return: decoded value

## Static Method: bytesToNumberSigned
- parameter: `bo`, type: `java.nio.ByteOrder`
- parameter: `b`, type: `byte[]`
- return type: `long`

Description: Convert a byte array to a number, sign is extended to long, meaning that {0x88} will result in 0xFFFFFFFF\_FFFFFF88L
parameter: bo: byte order to use for decoding
parameter: b: input bytes
return: decoded signed value

## Static Method: bytesToNumberUnsigned
- parameter: `bo`, type: `java.nio.ByteOrder`
- parameter: `b`, type: `byte[]`
- return type: `long`

Description: Convert a byte array to a number, zero extended to long, meaning that {0x88} will result in 0x88L
parameter: bo: byte order to use for decoding
parameter: b: input bytes
return: decoded unsigned value

## Static Method: bytesToShort
- parameter: `array`, type: `byte[]`
- parameter: `offset`, type: `int`
- parameter: `order`, type: `java.nio.ByteOrder`
- return type: `short`

Description: Read 2 bytes and convert it to a short.
parameter: array: input buffer
parameter: offset: buffer offset
parameter: order: endianness
return: decoded value

## Static Method: intToBEBytes
- parameter: `v`, type: `int`
- return type: `byte[]`

Description: Convert a 32\-bit integer to a big\-endian encoded array of bytes.
parameter: v: input value
return: four\-byte big\-endian representation

## Static Method: intToBEBytes
- parameter: `v`, type: `int`
- parameter: `output`, type: `byte[]`

Description: Encode a 32\-bit integer to big\-endian bytes.
parameter: v: input value
parameter: output: output buffer

## Static Method: intToBEBytes
- parameter: `v`, type: `int`
- parameter: `output`, type: `byte[]`
- parameter: `offset`, type: `int`

Description: Encode a 32\-bit integer to big\-endian bytes.
parameter: v: input value
parameter: output: output buffer
parameter: offset: output offset

## Static Method: intToLEBytes
- parameter: `v`, type: `int`
- return type: `byte[]`

Description: Convert a 32\-bit integer to a little\-endian encoded array of bytes.
parameter: v: input value
return: four\-byte little\-endian representation

## Static Method: intToLEBytes
- parameter: `v`, type: `int`
- parameter: `output`, type: `byte[]`

Description: Encode a 32\-bit integer to little\-endian bytes.
parameter: v: input value
parameter: output: output buffer

## Static Method: intToLEBytes
- parameter: `v`, type: `int`
- parameter: `output`, type: `byte[]`
- parameter: `offset`, type: `int`

Description: Encode a 32\-bit integer to little\-endian bytes.
parameter: v: input value
parameter: output: output buffer
parameter: offset: output offset

## Static Method: littleEndianBytesToInt
- parameter: `array`, type: `byte[]`
- return type: `int`

Description: Decode a little\-endian 32\-bit integer at offset 0.
parameter: array: input bytes
return: decoded value

## Static Method: littleEndianBytesToInt
- parameter: `array`, type: `byte[]`
- parameter: `offset`, type: `int`
- return type: `int`

Description: Decode a little\-endian 32\-bit integer.
parameter: array: input bytes
parameter: offset: input offset
return: decoded value

## Static Method: littleEndianBytesToLong
- parameter: `array`, type: `byte[]`
- return type: `long`

Description: Decode a little\-endian 64\-bit integer at offset 0.
parameter: array: input bytes
return: decoded value

## Static Method: littleEndianBytesToLong
- parameter: `array`, type: `byte[]`
- parameter: `offset`, type: `int`
- return type: `long`

Description: Decode a little\-endian 64\-bit integer.
parameter: array: input bytes
parameter: offset: input offset
return: decoded value

## Static Method: littleEndianBytesToShort
- parameter: `array`, type: `byte[]`
- return type: `short`

Description: Decode a little\-endian 16\-bit integer at offset 0.
parameter: array: input bytes
return: decoded value

## Static Method: littleEndianBytesToShort
- parameter: `array`, type: `byte[]`
- parameter: `offset`, type: `int`
- return type: `short`

Description: Decode a little\-endian 16\-bit integer.
parameter: array: input bytes
parameter: offset: input offset
return: decoded value

## Static Method: longToBEBytes
- parameter: `v`, type: `long`
- return type: `byte[]`

Description: Convert a 64\-bit integer to a big\-endian encoded array of bytes.
parameter: v: input value
return: eight\-byte big\-endian representation

## Static Method: longToBEBytes
- parameter: `v`, type: `long`
- parameter: `output`, type: `byte[]`

Description: Encode a 64\-bit integer to big\-endian bytes.
parameter: v: input value
parameter: output: output buffer

## Static Method: longToBEBytes
- parameter: `v`, type: `long`
- parameter: `output`, type: `byte[]`
- parameter: `offset`, type: `int`

Description: Encode a 64\-bit integer to big\-endian bytes.
parameter: v: input value
parameter: output: output buffer
parameter: offset: output offset

## Static Method: longToLEBytes
- parameter: `v`, type: `long`
- return type: `byte[]`

Description: Convert a 64\-bit integer to a little\-endian encoded array of bytes.
parameter: v: input value
return: eight\-byte little\-endian representation

## Static Method: longToLEBytes
- parameter: `v`, type: `long`
- parameter: `output`, type: `byte[]`

Description: Encode a 64\-bit integer to little\-endian bytes.
parameter: v: input value
parameter: output: output buffer

## Static Method: longToLEBytes
- parameter: `v`, type: `long`
- parameter: `output`, type: `byte[]`
- parameter: `offset`, type: `int`

Description: Encode a 64\-bit integer to little\-endian bytes.
parameter: v: input value
parameter: output: output buffer
parameter: offset: output offset

## Static Method: numberToBytes
- parameter: `bo`, type: `java.nio.ByteOrder`
- parameter: `v`, type: `long`
- parameter: `output`, type: `byte[]`

Description: Automatically convert a value depending on the byte array size. If size if not a pow of two, the floor pow of two is filled \(for example is size is 5, value will be considered as integer\). byte\[\] of more than 8 bytes will be cropped. This function is a bridge to xxxToLEBytes and xxxToBEBytes functions.
parameter: bo: byte order to use for output value
parameter: v: input value
parameter: output: output representation of v, using the given ByteOrder

## Static Method: shortToBEBytes
- parameter: `v`, type: `short`
- return type: `byte[]`

Description: Convert a 16\-bit integer to a big\-endian encoded array of bytes.
parameter: v: input value
return: two\-byte big\-endian representation

## Static Method: shortToBEBytes
- parameter: `v`, type: `short`
- parameter: `output`, type: `byte[]`

Description: Encode a 16\-bit integer to big\-endian bytes.
parameter: v: input value
parameter: output: output buffer

## Static Method: shortToBEBytes
- parameter: `v`, type: `short`
- parameter: `output`, type: `byte[]`
- parameter: `offset`, type: `int`

Description: Encode a 16\-bit integer to big\-endian bytes.
parameter: v: input value
parameter: output: output buffer
parameter: offset: output offset

## Static Method: shortToLEBytes
- parameter: `v`, type: `short`
- return type: `byte[]`

Description: Convert a 16\-bit integer to a little\-endian encoded array of bytes.
parameter: v: input value
return: two\-byte little\-endian representation

## Static Method: shortToLEBytes
- parameter: `v`, type: `short`
- parameter: `output`, type: `byte[]`

Description: Encode a 16\-bit integer to little\-endian bytes.
parameter: v: input value
parameter: output: output buffer

## Static Method: shortToLEBytes
- parameter: `v`, type: `short`
- parameter: `output`, type: `byte[]`
- parameter: `offset`, type: `int`

Description: Encode a 16\-bit integer to little\-endian bytes.
parameter: v: input value
parameter: output: output buffer
parameter: offset: output offset

## Static Method: swap
- parameter: `array`, type: `byte[]`
- parameter: `offset`, type: `int`
- parameter: `size`, type: `int`

Description: Flip the byte order of an array of bytes. This method does not create a new array.
parameter: array: the input/output array
parameter: offset: start index
parameter: size: number of elements to flip

## Static Method: swap
- parameter: `array`, type: `byte[]`

Description: Flip the byte order of an array of bytes. This method does not create a new array.
parameter: array: the input/output array

## Static Method: swapByGroup
- parameter: `array`, type: `byte[]`
- parameter: `grpByteCount`, type: `int`

Description: Flip the byte order of groups of bytes. This method does not create a new array.
parameter: array: byte array to change
parameter: grpByteCount: number of bytes per group \(2 for 16 bits, 4 for 32 bits, 8 for 64 bits\)

## Static Method: swapInt
- parameter: `v`, type: `int`
- return type: `int`

Description: Swap the byte ordering of an int.
parameter: v: input value
return: byte\-swapped value

## Static Method: swapLong
- parameter: `v`, type: `long`
- return type: `long`

Description: Swap the byte ordering of a long.
parameter: v: input value
return: byte\-swapped value

## Static Method: swapShort
- parameter: `v`, type: `short`
- return type: `short`

Description: Swap the byte ordering of a short.
parameter: v: input value
return: byte\-swapped value

