Class ByteConversions
java.lang.Object
org.apache.commons.imaging.common.ByteConversions
Convenience methods for converting data types to and from byte arrays.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static byte[]static byte[]static byte[]private static voidprivate static byte[]static byte[]static byte[]private static voidprivate static byte[]static byte[]static byte[]private static voidstatic byte[]Encodes an eight-byte (long) into an array of bytes based on the specified byte order.private static voidprivate static byte[]static byte[]static byte[]private static voidprivate static byte[]toBytes(RationalNumber[] values, int offset, int length, ByteOrder byteOrder) static byte[]toBytes(RationalNumber[] values, ByteOrder byteOrder) static byte[]toBytes(RationalNumber value, ByteOrder byteOrder) private static voidtoBytes(RationalNumber value, ByteOrder byteOrder, byte[] result, int offset) private static doublestatic doubleprivate static double[]static double[]private static floatstatic floatprivate static float[]static float[]static intstatic intprivate static int[]static int[]private static longstatic longExtracts an eight-byte long integer from the specified byte array.private static long[]static long[]Extracts an array of eight-byte long integers from the specified array of bytes.private static RationalNumbertoRational(byte[] bytes, int offset, ByteOrder byteOrder, boolean unsignedType) static RationalNumbertoRational(byte[] bytes, ByteOrder byteOrder, boolean unsignedType) Interprets the content of a specified bytes array to create an instance of the RationalNumber class.private static RationalNumber[]toRationals(byte[] bytes, int offset, int length, ByteOrder byteOrder, boolean unsignedType) static RationalNumber[]toRationals(byte[] bytes, ByteOrder byteOrder, boolean unsignedType) private static shortstatic shortprivate static short[]static short[]static intstatic intprivate static int[]static int[]
-
Constructor Details
-
ByteConversions
private ByteConversions()
-
-
Method Details
-
toBytes
-
toBytes
-
toBytes
-
toBytes
-
toBytes
-
toBytes
-
toBytes
-
toBytes
-
toBytes
-
toBytes
-
toBytes
-
toBytes
-
toBytes
Encodes an eight-byte (long) into an array of bytes based on the specified byte order.- Parameters:
value- a standard data primitive of type longbyteOrder- the byte order to be used for encoding- Returns:
- an array of length 8
-
toBytes
-
toBytes
-
toBytes
-
toBytes
-
toBytes
-
toBytes
-
toBytes
-
toBytes
-
toBytes
-
toDouble
-
toDouble
-
toDoubles
-
toDoubles
-
toFloat
-
toFloat
-
toFloats
-
toFloats
-
toInt
-
toInt
-
toInts
-
toInts
-
toLong
Extracts an eight-byte long integer from the specified byte array. This method assumes that the byte array is of sufficiently large size to encode a long integer.- Parameters:
bytes- an array of size at least 8byteOrder- the byte-order for interpreting the input bytes- Returns:
- an eight-byte signed integer
-
toLong
-
toLongs
Extracts an array of eight-byte long integers from the specified array of bytes. The size of the result array is computed based on the size of the input byte array.- Parameters:
bytes- a valid arraybyteOrder- the byte-order for interpreting the input bytes- Returns:
- an array of zero or more eight-byte signed integers
-
toLongs
-
toRational
Interprets the content of a specified bytes array to create an instance of the RationalNumber class.- Parameters:
bytes- a valid array dimensioned to at least 8.byteOrder- the byte order for integer conversionunsignedType- indicates whether the extracted value is an unsigned type.- Returns:
- a valid instance
-
toRational
private static RationalNumber toRational(byte[] bytes, int offset, ByteOrder byteOrder, boolean unsignedType) -
toRationals
-
toRationals
private static RationalNumber[] toRationals(byte[] bytes, int offset, int length, ByteOrder byteOrder, boolean unsignedType) -
toShort
-
toShort
-
toShorts
-
toShorts
-
toUInt16
-
toUInt16
-
toUInt16s
-
toUInt16s
-