Package ghidra.util
Class Conv
java.lang.Object
ghidra.util.Conv
Helper methods for converting between
number data types without negative
promotion.
Consider using java built-in methods for conversion instead of methods from this class.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDeprecated, for removal: This API element is subject to removal in a future version.static final longDeprecated, for removal: This API element is subject to removal in a future version.Integer.toUnsignedLong(int)will handle most use cases of this constantstatic final intDeprecated, for removal: This API element is subject to removal in a future version.Short.toUnsignedInt(short)will handle most use cases of this constant -
Method Summary
Modifier and TypeMethodDescriptionstatic intbyteToInt(byte b) Deprecated, for removal: This API element is subject to removal in a future version.UseByte.toUnsignedInt(byte)insteadstatic longbyteToLong(byte b) Deprecated, for removal: This API element is subject to removal in a future version.UseByte.toUnsignedLong(byte)insteadstatic shortbyteToShort(byte b) Deprecated, for removal: This API element is subject to removal in a future version.Use other built-ins likeByte.toUnsignedInt(byte)static longintToLong(int i) Deprecated, for removal: This API element is subject to removal in a future version.UseInteger.toUnsignedLong(int)insteadstatic intshortToInt(short s) Deprecated, for removal: This API element is subject to removal in a future version.UseShort.toUnsignedInt(short)insteadstatic longshortToLong(short s) Deprecated, for removal: This API element is subject to removal in a future version.UseShort.toUnsignedLong(short)insteadstatic StringtoHexString(byte b) Consider usingString.format("%02x", b)instead.static StringtoHexString(int i) Consider usingString.format("%08x", i)instead.static StringtoHexString(long l) Consider usingString.format("%016x", l)instead.static StringtoHexString(short s) Consider usingString.format("%04x", s)instead.static StringtoString(byte[] array) Deprecated, for removal: This API element is subject to removal in a future version.Usenew String(bytes, StandardCharSets.US_ASCII)insteadstatic StringReturns a string that is extended to length len with zeroes.
-
Field Details
-
BYTE_MASK
Deprecated, for removal: This API element is subject to removal in a future version.Byte.toUnsignedInt(byte)will handle most use cases of this constantA byte mask.- See Also:
-
SHORT_MASK
Deprecated, for removal: This API element is subject to removal in a future version.Short.toUnsignedInt(short)will handle most use cases of this constantA short mask.- See Also:
-
INT_MASK
Deprecated, for removal: This API element is subject to removal in a future version.Integer.toUnsignedLong(int)will handle most use cases of this constantAn integer mask.- See Also:
-
-
Method Details
-
byteToShort
Deprecated, for removal: This API element is subject to removal in a future version.Use other built-ins likeByte.toUnsignedInt(byte)- Parameters:
b- the byte- Returns:
- the short equivalent of the byte
-
byteToInt
Deprecated, for removal: This API element is subject to removal in a future version.UseByte.toUnsignedInt(byte)insteadConverts a byte to an integer.- Parameters:
b- the byte- Returns:
- the integer equivalent of the byte
-
byteToLong
Deprecated, for removal: This API element is subject to removal in a future version.UseByte.toUnsignedLong(byte)insteadConverts a byte to a long.- Parameters:
b- the byte- Returns:
- the long equivalent of the byte
-
shortToInt
Deprecated, for removal: This API element is subject to removal in a future version.UseShort.toUnsignedInt(short)insteadConverts a short to an integer.- Parameters:
s- the short- Returns:
- the integer equivalent of the short
-
shortToLong
Deprecated, for removal: This API element is subject to removal in a future version.UseShort.toUnsignedLong(short)insteadConverts a short to a long.- Parameters:
s- the short- Returns:
- the long eqivalent of the short
-
intToLong
Deprecated, for removal: This API element is subject to removal in a future version.UseInteger.toUnsignedLong(int)insteadConverts an integer to a long.- Parameters:
i- the integer- Returns:
- the long equivalent of the long
-
toString
Deprecated, for removal: This API element is subject to removal in a future version.Usenew String(bytes, StandardCharSets.US_ASCII)insteadOld and incorrect way to convert bytes to a String by casting their values to chars. Do not use. Does not seem to be used in current codebase.
- Parameters:
array-- Returns:
-
toHexString
Consider usingString.format("%02x", b)instead.Converts a byte into a padded hex string.
- Parameters:
b- the byte- Returns:
- the padded hex string
-
toHexString
Consider usingString.format("%04x", s)instead.Converts a short into a padded hex string.
- Parameters:
s- the short- Returns:
- the padded hex string
-
toHexString
Consider usingString.format("%08x", i)instead.Converts an integer into a padded hex string.
- Parameters:
i- the integer- Returns:
- the padded hex string
-
toHexString
Consider usingString.format("%016x", l)instead.Converts a long into a padded hex string.
- Parameters:
l- the long- Returns:
- the padded hex string
-
zeropad
Returns a string that is extended to length len with zeroes.- Parameters:
s- The string to padlen- The length of the return string- Returns:
- A string that has been left-padded with zeros to be of length len
-
Byte.toUnsignedInt(byte)will handle most use cases of this constant