Package com.luciad.util
Class TLcdByteConverter
java.lang.Object
com.luciad.util.TLcdByteConverter
This utility class regroups a set of methods for converting shorts, integers,
floats, and doubles to two, four, four, and eight bytes respectively,
and vice versa.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
doubleToEightByteSFCT
(double aDouble, byte[] aDestinationSFCT, int aStart) Converts a double to four bytes.static double
eightBytesToDouble
(byte[] aByteArray, int aStart) Converts eight bytes to a double.static double
eightBytesToDouble
(byte b1, byte b2, byte b3, byte b4, byte b5, byte b6, byte b7, byte b8) Converts eight bytes to a double.static void
floatToFourByteSFCT
(float aFloat, byte[] aDestinationSFCT, int aStart) Converts a float to four bytes.static double
fourBytesToDouble
(byte b1, byte b2, byte b3, byte b4) Converts four bytes to a double.static float
fourBytesToFloat
(byte b1, byte b2, byte b3, byte b4) Converts four bytes to a float.static int
fourBytesToInt
(byte[] aByteArray, int aStart) Converts four bytes to an integer.static int
fourBytesToInt
(byte b1, byte b2, byte b3, byte b4) Converts four bytes to an integer.static void
intToFourByteSFCT
(int aInt, byte[] aDestinationSFCT, int aStart) Converts an integer to four bytes.static void
shortToTwoByteSFCT
(short aShort, byte[] aDestinationSFCT, int aStart) Converts a short to two bytes.static short
twoBytesToShort
(byte b1, byte b2) Converts two bytes to a short.
-
Constructor Details
-
TLcdByteConverter
public TLcdByteConverter()
-
-
Method Details
-
shortToTwoByteSFCT
public static void shortToTwoByteSFCT(short aShort, byte[] aDestinationSFCT, int aStart) Converts a short to two bytes.- Parameters:
aShort
- the short to be converted.aDestinationSFCT
- the byte array in which the resulting bytes will be written, with the first byte placed ataStart
.aStart
- the index for the first output byte.
-
intToFourByteSFCT
public static void intToFourByteSFCT(int aInt, byte[] aDestinationSFCT, int aStart) Converts an integer to four bytes.- Parameters:
aInt
- the integer to be converted.aDestinationSFCT
- the byte array in which the resulting bytes will be written, with the first byte placed ataStart
.aStart
- the index for the first output byte.
-
floatToFourByteSFCT
public static void floatToFourByteSFCT(float aFloat, byte[] aDestinationSFCT, int aStart) Converts a float to four bytes.- Parameters:
aFloat
- the float to be converted.aDestinationSFCT
- the byte array in which the resulting bytes will be written, with the first byte placed ataStart
.aStart
- the index for the first output byte.
-
doubleToEightByteSFCT
public static void doubleToEightByteSFCT(double aDouble, byte[] aDestinationSFCT, int aStart) Converts a double to four bytes.- Parameters:
aDouble
- the double to be converted.aDestinationSFCT
- the byte array in which the resulting bytes will be written, with the first byte placed ataStart
.aStart
- the index for the first output byte.
-
twoBytesToShort
public static short twoBytesToShort(byte b1, byte b2) Converts two bytes to a short.- Parameters:
b1
- the first byte.b2
- the second byte.- Returns:
- the resulting short.
-
fourBytesToInt
public static int fourBytesToInt(byte[] aByteArray, int aStart) Converts four bytes to an integer.- Parameters:
aByteArray
- the byte array from which the bytes are retrieved, with the first byte starting ataStart
.aStart
- the index for the first input byte.- Returns:
- the resulting integer.
-
fourBytesToInt
public static int fourBytesToInt(byte b1, byte b2, byte b3, byte b4) Converts four bytes to an integer.- Parameters:
b1
- the first byte.b2
- the second byte.b3
- the third byte.b4
- the fourth byte.- Returns:
- the resulting integer.
-
fourBytesToFloat
public static float fourBytesToFloat(byte b1, byte b2, byte b3, byte b4) Converts four bytes to a float.- Parameters:
b1
- the first byte.b2
- the second byte.b3
- the third byte.b4
- the fourth byte.- Returns:
- the resulting float.
-
fourBytesToDouble
public static double fourBytesToDouble(byte b1, byte b2, byte b3, byte b4) Converts four bytes to a double.- Parameters:
b1
- the first byte.b2
- the second byte.b3
- the third byte.b4
- the fourth byte.- Returns:
- the resulting double.
-
eightBytesToDouble
public static double eightBytesToDouble(byte b1, byte b2, byte b3, byte b4, byte b5, byte b6, byte b7, byte b8) Converts eight bytes to a double.- Parameters:
b1
- through b8: the eight consecutive bytes.- Returns:
- the resulting double.
-
eightBytesToDouble
public static double eightBytesToDouble(byte[] aByteArray, int aStart) Converts eight bytes to a double.- Parameters:
aByteArray
- the byte array from which the bytes are retrieved, with the first byte starting ataStart
.aStart
- the index for the first input byte.- Returns:
- the resulting double.
-