Class 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 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,
                                 java.lang.Class<?> valueFieldClass,
                                 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.
        valueFieldClass - Field class 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 index.
        Parameters:
        index -
        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:
        start -
        end -
        value - value to be painted, or null for value removal.
        Throws:
        java.io.IOException
      • 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.
        AddressOverflowException - if the length is such that a address wrap occurs
      • clearRange

        public void clearRange​(Address startAddr,
                               Address endAddr)
        Remove values from the given range.
        Parameters:
        start -
        end -
      • 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 range
        endAddr - 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:
        register -
        addr -
        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 interface DBListener
        Parameters:
        dbh - associated database handle
        See Also:
        ghidra.framework.store.db.DBListener#dbRestored(db.DBHandle)
      • 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 interface DBListener
        Parameters:
        dbh - associated database handle
        See Also:
        ghidra.framework.store.db.DBListener#tableDeleted(db.DBHandle, ghidra.framework.store.db.Table)
      • 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 interface DBListener
        Parameters:
        dbh - associated database handle
        See Also:
        ghidra.framework.store.db.DBListener#tableAdded(db.DBHandle, ghidra.framework.store.db.Table)
      • dispose

        public void dispose()
        Deletes the database table used to store this range map.