Class ByteUtil
java.lang.Object
org.opendaylight.openflowplugin.openflow.md.util.ByteUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
bytesToHexstring
(byte[] bytes, String delimiter) Converts bytes to a hex string.static org.opendaylight.yangtools.yang.common.Uint32
bytesToUnsignedInt
(byte[] bytes) Converts a 4 byte array of unsigned bytes to unsigned int.static long
bytesToUnsignedMedium
(byte[] bytes) Converts a 3 byte array of unsigned bytes to unsigned int.static int
bytesToUnsignedShort
(byte[] bytes) Converts a 2 byte array of unsigned bytes to unsigned short.static byte @Nullable []
convertBigIntegerToNBytes
(@Nullable BigInteger bigInteger, int numBytes) Utility method to convert BigInteger to n element byte array.static byte @Nullable []
uint64toBytes
(@Nullable org.opendaylight.yangtools.yang.common.Uint64 uint) Utility method to convert an Uint64 to an 8-byte array.static byte[]
unsignedIntToBytes
(Long unsignedInt) Converts unsigned integer to a 4 byte array of unsigned bytes.static byte[]
unsignedIntToBytes
(org.opendaylight.yangtools.yang.common.Uint32 unsignedInt) Converts unsigned integer to a 4 byte array of unsigned bytes.static byte[]
unsignedMediumToBytes
(Long unsignedInt) Converts unsigned integer to a 3 byte array of unsigned bytes.static byte[]
unsignedMediumToBytes
(org.opendaylight.yangtools.yang.common.Uint32 unsignedInt) Converts unsigned integer to a 3 byte array of unsigned bytes.static byte[]
unsignedShortToBytes
(Integer unsignedShort) Converts unsigned short to a 2 byte array of unsigned bytes.static byte[]
unsignedShortToBytes
(org.opendaylight.yangtools.yang.common.Uint16 unsignedShort) Converts unsigned short to a 2 byte array of unsigned bytes.
-
Method Details
-
bytesToHexstring
Converts bytes to a hex string.- Parameters:
bytes
- bytes that needs to be converted to hexdelimiter
- string delimiter- Returns:
- hexString containing bytes, separated with delimiter
-
convertBigIntegerToNBytes
public static byte @Nullable [] convertBigIntegerToNBytes(@Nullable BigInteger bigInteger, int numBytes) Utility method to convert BigInteger to n element byte array.- Parameters:
bigInteger
- big integer value that needs to be converted to bytenumBytes
- convert to number of bytes- Returns:
- byte array containing n * 8 bits.
-
uint64toBytes
public static byte @Nullable [] uint64toBytes(@Nullable org.opendaylight.yangtools.yang.common.Uint64 uint) Utility method to convert an Uint64 to an 8-byte array.- Parameters:
uint
- Unsigned long, potentially null.- Returns:
- byte array, or null if input was null.
-
bytesToUnsignedInt
public static org.opendaylight.yangtools.yang.common.Uint32 bytesToUnsignedInt(byte[] bytes) Converts a 4 byte array of unsigned bytes to unsigned int.- Parameters:
bytes
- an array of 4 unsigned bytes- Returns:
- a long representing the unsigned int
-
bytesToUnsignedMedium
public static long bytesToUnsignedMedium(byte[] bytes) Converts a 3 byte array of unsigned bytes to unsigned int.- Parameters:
bytes
- an array of 4 unsigned bytes- Returns:
- a long representing the unsigned int
-
bytesToUnsignedShort
public static int bytesToUnsignedShort(byte[] bytes) Converts a 2 byte array of unsigned bytes to unsigned short.- Parameters:
bytes
- an array of 2 unsigned bytes- Returns:
- an int representing the unsigned short
-
unsignedIntToBytes
Converts unsigned integer to a 4 byte array of unsigned bytes.- Parameters:
unsignedInt
- representing the unsigned integer- Returns:
- bytes an array of 4 unsigned bytes
-
unsignedIntToBytes
public static byte[] unsignedIntToBytes(org.opendaylight.yangtools.yang.common.Uint32 unsignedInt) Converts unsigned integer to a 4 byte array of unsigned bytes.- Parameters:
unsignedInt
- representing the unsigned integer- Returns:
- bytes an array of 4 unsigned bytes
-
unsignedMediumToBytes
Converts unsigned integer to a 3 byte array of unsigned bytes.- Parameters:
unsignedInt
- representing the unsigned integer- Returns:
- bytes an array of 3 unsigned bytes
-
unsignedMediumToBytes
public static byte[] unsignedMediumToBytes(org.opendaylight.yangtools.yang.common.Uint32 unsignedInt) Converts unsigned integer to a 3 byte array of unsigned bytes.- Parameters:
unsignedInt
- representing the unsigned integer- Returns:
- bytes an array of 3 unsigned bytes
-
unsignedShortToBytes
Converts unsigned short to a 2 byte array of unsigned bytes.- Parameters:
unsignedShort
- representing the unsigned short- Returns:
- bytes an array of 2 unsigned bytes
-
unsignedShortToBytes
public static byte[] unsignedShortToBytes(org.opendaylight.yangtools.yang.common.Uint16 unsignedShort) Converts unsigned short to a 2 byte array of unsigned bytes.- Parameters:
unsignedShort
- representing the unsigned short- Returns:
- bytes an array of 2 unsigned bytes
-