Package ghidra.util
Class LittleEndianDataConverter
- java.lang.Object
-
- ghidra.util.LittleEndianDataConverter
-
- All Implemented Interfaces:
DataConverter,java.io.Serializable
- Direct Known Subclasses:
GhidraLittleEndianDataConverter
public class LittleEndianDataConverter extends java.lang.Object implements DataConverter
Helper class to convert a byte array to a Java primitive in Little endian order, and to convert a primitive to a byte array.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static LittleEndianDataConverterINSTANCE
-
Constructor Summary
Constructors Constructor Description LittleEndianDataConverter()Constructor for BigEndianDataConverter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.math.BigIntegergetBigInteger(byte[] b, int size, boolean signed)Get the value from the given byte array using the specified size.java.math.BigIntegergetBigInteger(byte[] b, int offset, int size, boolean signed)Get the value from the given byte array using the specified size.byte[]getBytes(int value)Converts the int value to an array of bytes.voidgetBytes(int value, byte[] b)Converts the given value to bytes.voidgetBytes(int value, byte[] b, int offset)Converts the given value to bytes.byte[]getBytes(long value)Converts the long value to an array of bytes.voidgetBytes(long value, byte[] b)Converts the given value to bytes.voidgetBytes(long value, byte[] b, int offset)Converts the given value to bytes.voidgetBytes(long value, int size, byte[] b, int offset)Converts the given value to bytes using the number of least significant bytes specified by size.byte[]getBytes(short value)Converts the short value to an array of bytes.voidgetBytes(short value, byte[] b)Converts the given value to bytes.voidgetBytes(short value, byte[] b, int offset)Converts the given value to bytes.byte[]getBytes(java.math.BigInteger value, int size)Converts the value to an array of bytes.voidgetBytes(java.math.BigInteger value, int size, byte[] b, int offset)Converts the given value to bytes using the number of least significant bytes specified by size.intgetInt(byte[] b)Get the int value from the given byte array.intgetInt(byte[] b, int offset)Get the int value from the given byte array.longgetLong(byte[] b)Get the long value from the given byte array.longgetLong(byte[] b, int offset)Get the long value from the given byte array.shortgetShort(byte[] b)Get the short value from the given byte array.shortgetShort(byte[] b, int offset)Get the short value from the given byte array.longgetValue(byte[] b, int size)Get the value from the given byte array using the specified size.longgetValue(byte[] b, int offset, int size)Get the value from the given byte array using the specified size.voidputBigInteger(byte[] b, int offset, int size, java.math.BigInteger value)Writes a value of specified size into the byte array at the given offsetvoidputBigInteger(byte[] b, int size, java.math.BigInteger value)Writes a value of specified size into the byte array at the given offsetvoidputInt(byte[] b, int value)Writes a int value into a byte array.voidputInt(byte[] b, int offset, int value)Writes a int value into the byte array at the given offsetvoidputLong(byte[] b, int offset, long value)Writes a long value into the byte array at the given offsetvoidputLong(byte[] b, long value)Writes a long value into a byte array.voidputShort(byte[] b, int offset, short value)Writes a short value into the byte array at the given offsetvoidputShort(byte[] b, short value)Writes a short value into a byte array.
-
-
-
Field Detail
-
INSTANCE
public static LittleEndianDataConverter INSTANCE
-
-
Method Detail
-
getShort
public final short getShort(byte[] b)
Description copied from interface:DataConverterGet the short value from the given byte array.- Specified by:
getShortin interfaceDataConverter- Parameters:
b- array containing bytes- See Also:
DataConverter.getShort(byte[])
-
getShort
public short getShort(byte[] b, int offset)Description copied from interface:DataConverterGet the short value from the given byte array.- Specified by:
getShortin interfaceDataConverter- Parameters:
b- array containing bytesoffset- offset into byte array for getting the short- See Also:
DataConverter.getShort(byte[], int)
-
getInt
public final int getInt(byte[] b)
Description copied from interface:DataConverterGet the int value from the given byte array.- Specified by:
getIntin interfaceDataConverter- Parameters:
b- array containing bytes- See Also:
DataConverter.getInt(byte[])
-
getInt
public int getInt(byte[] b, int offset)Description copied from interface:DataConverterGet the int value from the given byte array.- Specified by:
getIntin interfaceDataConverter- Parameters:
b- array containing bytesoffset- offset into byte array for getting the int- See Also:
DataConverter.getInt(byte[], int)
-
getLong
public final long getLong(byte[] b)
Description copied from interface:DataConverterGet the long value from the given byte array.- Specified by:
getLongin interfaceDataConverter- Parameters:
b- array containing bytes- See Also:
DataConverter.getLong(byte[])
-
getLong
public long getLong(byte[] b, int offset)Description copied from interface:DataConverterGet the long value from the given byte array.- Specified by:
getLongin interfaceDataConverter- Parameters:
b- array containing bytesoffset- offset into byte array for getting the long- See Also:
DataConverter.getLong(byte[], int)
-
getValue
public long getValue(byte[] b, int size)Description copied from interface:DataConverterGet the value from the given byte array using the specified size.- Specified by:
getValuein interfaceDataConverter- Parameters:
b- array containing bytessize- number of bytes to use from array at offset 0- See Also:
DataConverter.getValue(byte[], int)
-
getValue
public long getValue(byte[] b, int offset, int size)Description copied from interface:DataConverterGet the value from the given byte array using the specified size.- Specified by:
getValuein interfaceDataConverter- Parameters:
b- array containing bytesoffset- offset into byte array for getting the longsize- number of bytes to use from array- See Also:
DataConverter.getValue(byte[], int, int)
-
getBigInteger
public final java.math.BigInteger getBigInteger(byte[] b, int size, boolean signed)Description copied from interface:DataConverterGet the value from the given byte array using the specified size.- Specified by:
getBigIntegerin interfaceDataConverter- Parameters:
b- array containing bytessize- number of bytes to use from array at offset 0
-
getBigInteger
public final java.math.BigInteger getBigInteger(byte[] b, int offset, int size, boolean signed)Description copied from interface:DataConverterGet the value from the given byte array using the specified size.- Specified by:
getBigIntegerin interfaceDataConverter- Parameters:
b- array containing bytesoffset- offset into byte array for getting the longsize- number of bytes to use from array
-
getBytes
public final void getBytes(short value, byte[] b)Description copied from interface:DataConverterConverts the given value to bytes.- Specified by:
getBytesin interfaceDataConverter- Parameters:
value- value to convert to bytesb- byte array to store bytes- See Also:
DataConverter.getBytes(short, byte[])
-
getBytes
public void getBytes(short value, byte[] b, int offset)Description copied from interface:DataConverterConverts the given value to bytes.- Specified by:
getBytesin interfaceDataConverter- Parameters:
value- value to convert to bytesb- byte array to store bytesoffset- offset into byte array to put the bytes- See Also:
DataConverter.getBytes(short, byte[], int)
-
getBytes
public final void getBytes(int value, byte[] b)Description copied from interface:DataConverterConverts the given value to bytes.- Specified by:
getBytesin interfaceDataConverter- Parameters:
value- value to convert to bytesb- byte array to store bytes- See Also:
DataConverter.getBytes(int, byte[])
-
getBytes
public void getBytes(int value, byte[] b, int offset)Description copied from interface:DataConverterConverts the given value to bytes.- Specified by:
getBytesin interfaceDataConverter- Parameters:
value- value to convert to bytesb- byte array to store bytesoffset- offset into byte array to put the bytes- See Also:
DataConverter.getBytes(int, byte[], int)
-
getBytes
public final void getBytes(long value, byte[] b)Description copied from interface:DataConverterConverts the given value to bytes.- Specified by:
getBytesin interfaceDataConverter- Parameters:
value- value to convert to bytesb- byte array to store bytes- See Also:
DataConverter.getBytes(long, byte[])
-
getBytes
public void getBytes(long value, byte[] b, int offset)Description copied from interface:DataConverterConverts the given value to bytes.- Specified by:
getBytesin interfaceDataConverter- Parameters:
value- value to convert to bytesb- byte array to store bytesoffset- offset into byte array to put the bytes- See Also:
DataConverter.getBytes(long, byte[], int)
-
getBytes
public void getBytes(long value, int size, byte[] b, int offset)Description copied from interface:DataConverterConverts the given value to bytes using the number of least significant bytes specified by size.- Specified by:
getBytesin interfaceDataConverter- Parameters:
value- value to convert to bytessize- number of least significant bytes of value to be written to the byte arrayb- byte array to store bytesoffset- offset into byte array to put the bytes- See Also:
DataConverter.getBytes(long, int, byte[], int)
-
putInt
public final void putInt(byte[] b, int offset, int value)Description copied from interface:DataConverterWrites a int value into the byte array at the given offset- Specified by:
putIntin interfaceDataConverter- Parameters:
b- array to contain the bytes;offset- the offset into the byte array to store the value.value- the int value- See Also:
DataConverter.putInt(byte[], int, int)
-
putInt
public final void putInt(byte[] b, int value)Description copied from interface:DataConverterWrites a int value into a byte array.- Specified by:
putIntin interfaceDataConverter- Parameters:
b- array to contain the bytes;value- the int value- See Also:
DataConverter.putInt(byte[], int)
-
putLong
public final void putLong(byte[] b, int offset, long value)Description copied from interface:DataConverterWrites a long value into the byte array at the given offset- Specified by:
putLongin interfaceDataConverter- Parameters:
b- array to contain the bytes;offset- the offset into the byte array to store the value.value- the long value- See Also:
DataConverter.putLong(byte[], int, long)
-
putLong
public final void putLong(byte[] b, long value)Description copied from interface:DataConverterWrites a long value into a byte array.- Specified by:
putLongin interfaceDataConverter- Parameters:
b- array to contain the bytes;value- the long value- See Also:
DataConverter.putLong(byte[], long)
-
putShort
public final void putShort(byte[] b, int offset, short value)Description copied from interface:DataConverterWrites a short value into the byte array at the given offset- Specified by:
putShortin interfaceDataConverter- Parameters:
b- array to contain the bytes;offset- the offset into the byte array to store the value.value- the short value- See Also:
DataConverter.putShort(byte[], int, short)
-
putShort
public final void putShort(byte[] b, short value)Description copied from interface:DataConverterWrites a short value into a byte array.- Specified by:
putShortin interfaceDataConverter- Parameters:
b- array to contain the bytes;value- the short value- See Also:
DataConverter.putShort(byte[], short)
-
getBytes
public byte[] getBytes(int value)
Description copied from interface:DataConverterConverts the int value to an array of bytes.- Specified by:
getBytesin interfaceDataConverter- Parameters:
value- int value to be converted- Returns:
- array of bytes
- See Also:
DataConverter.getBytes(int)
-
getBytes
public byte[] getBytes(long value)
Description copied from interface:DataConverterConverts the long value to an array of bytes.- Specified by:
getBytesin interfaceDataConverter- Parameters:
value- long value to be converted- Returns:
- array of bytes
- See Also:
DataConverter.getBytes(long)
-
getBytes
public byte[] getBytes(short value)
Description copied from interface:DataConverterConverts the short value to an array of bytes.- Specified by:
getBytesin interfaceDataConverter- Parameters:
value- short value to be converted- Returns:
- array of bytes
- See Also:
DataConverter.getBytes(short)
-
getBytes
public byte[] getBytes(java.math.BigInteger value, int size)Description copied from interface:DataConverterConverts the value to an array of bytes.- Specified by:
getBytesin interfaceDataConverter- Parameters:
value- value to be convertedsize- value size in bytes- Returns:
- array of bytes
-
getBytes
public void getBytes(java.math.BigInteger value, int size, byte[] b, int offset)Description copied from interface:DataConverterConverts the given value to bytes using the number of least significant bytes specified by size.- Specified by:
getBytesin interfaceDataConverter- Parameters:
value- value to convert to bytessize- number of least significant bytes of value to be written to the byte arrayb- byte array to store bytesoffset- offset into byte array to put the bytes
-
putBigInteger
public void putBigInteger(byte[] b, int offset, int size, java.math.BigInteger value)Description copied from interface:DataConverterWrites a value of specified size into the byte array at the given offset- Specified by:
putBigIntegerin interfaceDataConverter- Parameters:
b- array to contain the bytes;offset- the offset into the byte array to store the value.size- number of bytes to be written
-
putBigInteger
public void putBigInteger(byte[] b, int size, java.math.BigInteger value)Description copied from interface:DataConverterWrites a value of specified size into the byte array at the given offset- Specified by:
putBigIntegerin interfaceDataConverter- Parameters:
b- array to contain the bytes at offset 0;size- number of bytes to be written
-
-