Package ghidra.program.database.util
Class AddressRangeMapDB
- java.lang.Object
-
- ghidra.program.database.util.AddressRangeMapDB
-
- All Implemented Interfaces:
DBListener
public class AddressRangeMapDB extends java.lang.Object implements DBListener
RangeMapDB
provides a generic value range map backed by a database table. A given range may be occupied by at most a single value which is painted over that range.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
RANGE_MAP_TABLE_PREFIX
-
Constructor Summary
Constructors Constructor Description AddressRangeMapDB(DBHandle dbHandle, AddressMap addrMap, Lock lock, java.lang.String name, ErrorHandler errHandler, Field valueField, boolean indexed)
Construct a generic range map.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearRange(Address startAddr, Address endAddr)
Remove values from the given range.void
dbClosed(DBHandle dbh)
Database has been closedvoid
dbRestored(DBHandle dbh)
Provides notification that an undo or redo was performed.void
dispose()
Deletes the database table used to store this range map.static boolean
exists(DBHandle dbHandle, java.lang.String name)
AddressRange
getAddressRangeContaining(Address addr)
Returns the bounding address-range containing addr and the the same value throughout.AddressRangeIterator
getAddressRanges()
Returns an address range iterator over all occupied ranges in the map.AddressRangeIterator
getAddressRanges(Address startAddr)
Returns an address range iterator over all occupied ranges in the map.AddressRangeIterator
getAddressRanges(Address startAddr, Address endAddr)
Returns an address range iterator over all occupied ranges whose FROM address falls within the range startAddr to endAddr.AddressSet
getAddressSet()
Returns a complete address set where any value has been set.AddressSet
getAddressSet(Field value)
Returns a complete address set where the specified value has been set.int
getRecordCount()
Returns the number of records contained within this map.Field
getValue(Address addr)
Returns the value associated with the given address.AddressRangeIterator
getValueRanges(Field value)
Returns an address range iterator for those ranges which contain the specified value.boolean
isEmpty()
Returns true if this map is emptyvoid
moveAddressRange(Address fromAddr, Address toAddr, long length, TaskMonitor monitor)
Move all values within an address range to a new range.void
paintRange(Address startAddr, Address endAddr, Field value)
Associates the given value with every index from start to end (inclusive) Any previous associates are overwritten.boolean
setName(java.lang.String newName)
Set the name associated with this range map.void
tableAdded(DBHandle dbh, Table table)
Provides notification that a table was added.void
tableDeleted(DBHandle dbh, Table table)
Provides notification that a table was deleted.
-
-
-
Field Detail
-
RANGE_MAP_TABLE_PREFIX
public static final java.lang.String RANGE_MAP_TABLE_PREFIX
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AddressRangeMapDB
public AddressRangeMapDB(DBHandle dbHandle, AddressMap addrMap, Lock lock, java.lang.String name, ErrorHandler errHandler, Field valueField, boolean indexed)
Construct a generic range map.- Parameters:
dbHandle
- database handle.name
- map name used in naming the underlying database table. This name must be unique across all range maps.errHandler
- database error handler.valueField
- Field to be used for stored values.indexed
- if true, values will be indexed allowing use of the getValueRangeIterator method.
-
-
Method Detail
-
setName
public boolean setName(java.lang.String newName) throws DuplicateNameException
Set the name associated with this range map.- Parameters:
newName
-- Returns:
- true if successful, else false
- Throws:
DuplicateNameException
-
exists
public static boolean exists(DBHandle dbHandle, java.lang.String name)
-
isEmpty
public boolean isEmpty()
Returns true if this map is empty
-
getRecordCount
public int getRecordCount()
Returns the number of records contained within this map. NOTE: This number will be greater or equal to the number of address ranges contained within the map.- Returns:
- record count
-
getValue
public Field getValue(Address addr)
Returns the value associated with the given address.- Parameters:
addr
- the address of the value- Returns:
- value or null no value exists
-
paintRange
public void paintRange(Address startAddr, Address endAddr, Field value)
Associates the given value with every index from start to end (inclusive) Any previous associates are overwritten.- Parameters:
startAddr
- the start address.endAddr
- the end address.value
- value to be painted, or null for value removal.
-
moveAddressRange
public void moveAddressRange(Address fromAddr, Address toAddr, long length, TaskMonitor monitor) throws CancelledException
Move all values within an address range to a new range.- Parameters:
fromAddr
- the first address of the range to be moved.toAddr
- the address where to the range is to be moved.length
- the number of addresses to move.monitor
- the task monitor.- Throws:
CancelledException
- if the user canceled the operation via the task monitor.
-
clearRange
public void clearRange(Address startAddr, Address endAddr)
Remove values from the given range.- Parameters:
startAddr
- the start address.endAddr
- the end address.
-
getAddressSet
public AddressSet getAddressSet()
Returns a complete address set where any value has been set.- Returns:
- address set
-
getAddressSet
public AddressSet getAddressSet(Field value)
Returns a complete address set where the specified value has been set.- Parameters:
value
- field value- Returns:
- address set
-
getAddressRanges
public AddressRangeIterator getAddressRanges()
Returns an address range iterator over all occupied ranges in the map.- Returns:
- AddressRangeIterator that iterates over all occupied ranges in th map.
-
getAddressRanges
public AddressRangeIterator getAddressRanges(Address startAddr)
Returns an address range iterator over all occupied ranges in the map. The first range must have a FROM address at or after the specified startAddr.- Parameters:
startAddr
- the address to start the iterator.- Returns:
- AddressRangeIterator that iterates over all occupied ranges in th map.
-
getAddressRanges
public AddressRangeIterator getAddressRanges(Address startAddr, Address endAddr)
Returns an address range iterator over all occupied ranges whose FROM address falls within the range startAddr to endAddr.- Parameters:
startAddr
- start of rangeendAddr
- end of range- Returns:
- AddressRangeIterator
-
getValueRanges
public AddressRangeIterator getValueRanges(Field value)
Returns an address range iterator for those ranges which contain the specified value. This method may only be invoked for indexed maps.- Parameters:
value
-- Returns:
- AddressRangeIterator
-
getAddressRangeContaining
public AddressRange getAddressRangeContaining(Address addr)
Returns the bounding address-range containing addr and the the same value throughout.- Parameters:
addr
- the contained address- Returns:
- single value address-range containing addr
-
dbRestored
public void dbRestored(DBHandle dbh)
Description copied from interface:DBListener
Provides notification that an undo or redo was performed. Separate notification will be provided if tables were added/removed. The state of the database may still be in transition and should not be accessed by this callback method.- Specified by:
dbRestored
in interfaceDBListener
- Parameters:
dbh
- associated database handle
-
dbClosed
public void dbClosed(DBHandle dbh)
Description copied from interface:DBListener
Database has been closed- Specified by:
dbClosed
in interfaceDBListener
- Parameters:
dbh
- associated database handle
-
tableDeleted
public void tableDeleted(DBHandle dbh, Table table)
Description copied from interface:DBListener
Provides notification that a table was deleted. The state of the database may still be in transition and should not be accessed by this callback method.- Specified by:
tableDeleted
in interfaceDBListener
- Parameters:
dbh
- associated database handle
-
tableAdded
public void tableAdded(DBHandle dbh, Table table)
Description copied from interface:DBListener
Provides notification that a table was added. The state of the database may still be in transition and should not be accessed by this callback method.- Specified by:
tableAdded
in interfaceDBListener
- Parameters:
dbh
- associated database handle
-
dispose
public void dispose()
Deletes the database table used to store this range map.
-
-