Class ByteConversions
- java.lang.Object
-
- org.apache.commons.imaging.common.ByteConversions
-
public final class ByteConversions extends Object
Convenience methods for converting data types to and from byte arrays.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]
toBytes(double[] values, ByteOrder byteOrder)
static byte[]
toBytes(double value, ByteOrder byteOrder)
static byte[]
toBytes(float[] values, ByteOrder byteOrder)
static byte[]
toBytes(float value, ByteOrder byteOrder)
static byte[]
toBytes(int[] values, ByteOrder byteOrder)
static byte[]
toBytes(int value, ByteOrder byteOrder)
static byte[]
toBytes(short[] values, ByteOrder byteOrder)
static byte[]
toBytes(short value, ByteOrder byteOrder)
static byte[]
toBytes(RationalNumber[] values, ByteOrder byteOrder)
static byte[]
toBytes(RationalNumber value, ByteOrder byteOrder)
static double
toDouble(byte[] bytes, ByteOrder byteOrder)
static double[]
toDoubles(byte[] bytes, ByteOrder byteOrder)
static float
toFloat(byte[] bytes, ByteOrder byteOrder)
static float[]
toFloats(byte[] bytes, ByteOrder byteOrder)
static int
toInt(byte[] bytes, int offset, ByteOrder byteOrder)
static int
toInt(byte[] bytes, ByteOrder byteOrder)
static int[]
toInts(byte[] bytes, ByteOrder byteOrder)
static RationalNumber
toRational(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 short
toShort(byte[] bytes, ByteOrder byteOrder)
static short[]
toShorts(byte[] bytes, ByteOrder byteOrder)
static int
toUInt16(byte[] bytes, int offset, ByteOrder byteOrder)
static int
toUInt16(byte[] bytes, ByteOrder byteOrder)
static int[]
toUInt16s(byte[] bytes, ByteOrder byteOrder)
-
-
-
Method Detail
-
toBytes
public static byte[] toBytes(short value, ByteOrder byteOrder)
-
toBytes
public static byte[] toBytes(short[] values, ByteOrder byteOrder)
-
toBytes
public static byte[] toBytes(int value, ByteOrder byteOrder)
-
toBytes
public static byte[] toBytes(int[] values, ByteOrder byteOrder)
-
toBytes
public static byte[] toBytes(float value, ByteOrder byteOrder)
-
toBytes
public static byte[] toBytes(float[] values, ByteOrder byteOrder)
-
toBytes
public static byte[] toBytes(double value, ByteOrder byteOrder)
-
toBytes
public static byte[] toBytes(double[] values, ByteOrder byteOrder)
-
toBytes
public static byte[] toBytes(RationalNumber value, ByteOrder byteOrder)
-
toBytes
public static byte[] toBytes(RationalNumber[] values, ByteOrder byteOrder)
-
toShort
public static short toShort(byte[] bytes, ByteOrder byteOrder)
-
toShorts
public static short[] toShorts(byte[] bytes, ByteOrder byteOrder)
-
toUInt16
public static int toUInt16(byte[] bytes, ByteOrder byteOrder)
-
toUInt16
public static int toUInt16(byte[] bytes, int offset, ByteOrder byteOrder)
-
toUInt16s
public static int[] toUInt16s(byte[] bytes, ByteOrder byteOrder)
-
toInt
public static int toInt(byte[] bytes, ByteOrder byteOrder)
-
toInt
public static int toInt(byte[] bytes, int offset, ByteOrder byteOrder)
-
toInts
public static int[] toInts(byte[] bytes, ByteOrder byteOrder)
-
toFloat
public static float toFloat(byte[] bytes, ByteOrder byteOrder)
-
toFloats
public static float[] toFloats(byte[] bytes, ByteOrder byteOrder)
-
toDouble
public static double toDouble(byte[] bytes, ByteOrder byteOrder)
-
toDoubles
public static double[] toDoubles(byte[] bytes, ByteOrder byteOrder)
-
toRational
public static RationalNumber toRational(byte[] bytes, ByteOrder byteOrder, boolean unsignedType)
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
-
toRationals
public static RationalNumber[] toRationals(byte[] bytes, ByteOrder byteOrder, boolean unsignedType)
-
-