Class ByteConversions
java.lang.Object
org.apache.commons.imaging.common.ByteConversions
Convenience methods for converting data types to and from byte arrays.
- 
Method SummaryModifier and TypeMethodDescriptionstatic byte[]static byte[]static byte[]static byte[]static byte[]static byte[]static byte[]Encodes an eight-byte (long) into an array of bytes based on the specified byte order.static byte[]static byte[]static byte[]toBytes(RationalNumber[] values, ByteOrder byteOrder) static byte[]toBytes(RationalNumber value, ByteOrder byteOrder) static doublestatic double[]static floatstatic float[]static intstatic intstatic int[]static longExtracts an eight-byte long integer from the specified byte array.static long[]Extracts an array of eight-byte long integers from the specified array of bytes.static RationalNumbertoRational(byte[] bytes, ByteOrder byteOrder, boolean unsignedType) Interprets the content of a specified bytes array to create an instance of the RationalNumber class.static RationalNumber[]toRationals(byte[] bytes, ByteOrder byteOrder, boolean unsignedType) static shortstatic short[]static intstatic intstatic int[]
- 
Method Details- 
toBytes
- 
toBytes
- 
toBytes
- 
toBytes
- 
toBytes
- 
toBytes
- 
toBytesEncodes an eight-byte (long) into an array of bytes based on the specified byte order.- Parameters:
- value- a standard data primitive of type long
- byteOrder- the byte order to be used for encoding
- Returns:
- an array of length 8
 
- 
toBytes
- 
toBytes
- 
toBytes
- 
toBytes
- 
toDouble
- 
toDoubles
- 
toFloat
- 
toFloats
- 
toInt
- 
toInt
- 
toInts
- 
toLongExtracts 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 8
- byteOrder- the byte-order for interpreting the input bytes
- Returns:
- an eight-byte signed integer
 
- 
toLongsExtracts 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 array
- byteOrder- the byte-order for interpreting the input bytes
- Returns:
- an array of zero or more eight-byte signed integers
 
- 
toRationalInterprets 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 conversion
- unsignedType- indicates whether the extracted value is an unsigned type.
- Returns:
- a valid instance
 
- 
toRationals
- 
toShort
- 
toShorts
- 
toUInt16
- 
toUInt16
- 
toUInt16s
 
-