Class BookmarkDBManager

java.lang.Object
ghidra.program.database.bookmark.BookmarkDBManager
All Implemented Interfaces:
ErrorHandler, ManagerDB, BookmarkManager

public class BookmarkDBManager extends Object implements BookmarkManager, ErrorHandler, ManagerDB
  • Constructor Details

    • BookmarkDBManager

      public BookmarkDBManager(DBHandle handle, AddressMap addrMap, OpenMode openMode, Lock lock, TaskMonitor monitor) throws VersionException, IOException
      Constructs a new CodeManager for a program.
      Parameters:
      handle - handle to database
      addrMap - addressMap to convert between addresses and long values.
      openMode - either READ_ONLY, UPDATE, or UPGRADE
      lock - the program synchronization lock
      monitor - the task monitor use while upgrading.
      Throws:
      VersionException - if the database is incompatible with the current schema
      IOException - if there is a problem accessing the database.
  • Method Details

    • setProgram

      public void setProgram(ProgramDB program)
      Description copied from interface: ManagerDB
      Callback from program used to indicate all manager have been created. When this method is invoked, all managers have been instantiated but may not be fully initialized.
      Specified by:
      setProgram in interface ManagerDB
      Parameters:
      program - the program is set when all the initializations have been completed.
    • programReady

      public void programReady(OpenMode openMode, int currentRevision, TaskMonitor monitor) throws IOException, CancelledException
      Description copied from interface: ManagerDB
      Callback from program made to each manager after the program has completed initialization. This method may be used by managers to perform additional upgrading which may have been deferred.
      Specified by:
      programReady in interface ManagerDB
      Parameters:
      openMode - the mode that the program is being opened.
      currentRevision - current program revision. If openMode is UPGRADE, this value reflects the pre-upgrade value.
      monitor - the task monitor to use in any upgrade operations.
      Throws:
      IOException - if a database io error occurs.
      CancelledException - if the user cancelled the operation via the task monitor.
    • dbError

      public void dbError(IOException e)
      Description copied from interface: ErrorHandler
      Notification that an IO exception occurred.
      Specified by:
      dbError in interface ErrorHandler
      Parameters:
      e - IOException which was cause of error
    • invalidateCache

      public void invalidateCache(boolean all)
      Invalidate cached objects held by this manager.
      Specified by:
      invalidateCache in interface ManagerDB
      Parameters:
      all - if false, some managers may not need to update their cache if they can tell that its not necessary. If this flag is true, then all managers should clear their cache no matter what.
    • defineType

      public BookmarkType defineType(String type, Icon icon, Color color, int priority)
      Description copied from interface: BookmarkManager
      Define a bookmark type with its marker icon and color. The icon and color values are not permanently stored. Therefor, this method must be re-invoked by a plugin each time a program is opened if a custom icon and color are desired.
      Specified by:
      defineType in interface BookmarkManager
      Parameters:
      type - bookmark type
      icon - marker icon which may get scaled
      color - marker color
      priority - the bookmark priority
      Returns:
      bookmark type object
    • getBookmarkTypes

      public BookmarkType[] getBookmarkTypes()
      Description copied from interface: BookmarkManager
      Returns list of known bookmark types
      Specified by:
      getBookmarkTypes in interface BookmarkManager
      Returns:
      list of known bookmark types
    • getProgram

      public Program getProgram()
      Description copied from interface: BookmarkManager
      Returns the program associated with this BookmarkManager.
      Specified by:
      getProgram in interface BookmarkManager
      Returns:
      the program associated with this BookmarkManager.
    • getBookmarkType

      public BookmarkType getBookmarkType(String type)
      Description copied from interface: BookmarkManager
      Get a bookmark type
      Specified by:
      getBookmarkType in interface BookmarkManager
      Parameters:
      type - bookmark type name
      Returns:
      bookmark type or null if type is unknown
    • setBookmark

      public Bookmark setBookmark(Address addr, String type, String category, String comment)
      Description copied from interface: BookmarkManager
      Set a bookmark.
      Specified by:
      setBookmark in interface BookmarkManager
      Parameters:
      addr - the address at which to set a bookmark
      type - the name of the bookmark type.
      category - the category for the bookmark.
      comment - the comment to associate with the bookmark.
      Returns:
      the new bookmark
    • getBookmark

      public Bookmark getBookmark(Address addr, String type, String category)
      Description copied from interface: BookmarkManager
      Get a specific bookmark
      Specified by:
      getBookmark in interface BookmarkManager
      Parameters:
      addr - the address of the bookmark to retrieve
      type - the name of the bookmark type.
      category - the category of the bookmark.
      Returns:
      the bookmark with the given attributes, or null if no bookmarks match.
    • removeBookmark

      public void removeBookmark(Bookmark bookmark)
      Description copied from interface: BookmarkManager
      Remove bookmark
      Specified by:
      removeBookmark in interface BookmarkManager
      Parameters:
      bookmark - the bookmark to remove.
    • removeBookmarks

      public void removeBookmarks(String type)
      Description copied from interface: BookmarkManager
      Removes all bookmarks of the given type.
      Specified by:
      removeBookmarks in interface BookmarkManager
      Parameters:
      type - bookmark type
    • removeBookmarks

      public void removeBookmarks(String type, String category, TaskMonitor monitor) throws CancelledException
      Description copied from interface: BookmarkManager
      Removes all bookmarks with the given type and category.
      Specified by:
      removeBookmarks in interface BookmarkManager
      Parameters:
      type - the type of the bookmarks to be removed.
      category - bookmark category of the types to be removed.
      monitor - a task monitor to report the progress.
      Throws:
      CancelledException - if the user (via the monitor) cancelled the operation.
    • getBookmarks

      public Bookmark[] getBookmarks(Address addr)
      Description copied from interface: BookmarkManager
      Get all bookmarks on a specific address
      Specified by:
      getBookmarks in interface BookmarkManager
      Parameters:
      addr - the address at which to retrieve all bookmarks.
      Returns:
      array of bookmarks
    • getBookmarks

      public Bookmark[] getBookmarks(Address address, String type)
      Description copied from interface: BookmarkManager
      Get bookmarks of the indicated type on a specific address
      Specified by:
      getBookmarks in interface BookmarkManager
      Parameters:
      address - the address at which to search for bookmarks.
      type - bookmark type to search for
      Returns:
      array of bookmarks
    • hasBookmarks

      public boolean hasBookmarks(String type)
      Description copied from interface: BookmarkManager
      Returns true if program contains one or more bookmarks of the given type
      Specified by:
      hasBookmarks in interface BookmarkManager
      Parameters:
      type - the type of bookmark to check for.
      Returns:
      true if program contains one or more bookmarks of the given type
    • getCategories

      public String[] getCategories(String type)
      Description copied from interface: BookmarkManager
      Get list of categories used for a specified type
      Specified by:
      getCategories in interface BookmarkManager
      Parameters:
      type - bookmark type
      Returns:
      array of category strings
    • getBookmarkAddresses

      public AddressSetView getBookmarkAddresses(String type)
      Description copied from interface: BookmarkManager
      Get addresses for bookmarks of a specified type.
      Specified by:
      getBookmarkAddresses in interface BookmarkManager
      Parameters:
      type - bookmark type
      Returns:
      address set containing bookmarks of the specified type.
    • getBookmark

      public Bookmark getBookmark(long id)
      Description copied from interface: BookmarkManager
      Returns the bookmark that has the given id or null if no such bookmark exists.
      Specified by:
      getBookmark in interface BookmarkManager
      Parameters:
      id - the id of the bookmark to be retrieved.
      Returns:
      the bookmark
    • getBookmarkCount

      public int getBookmarkCount()
      Description copied from interface: BookmarkManager
      Returns the total number of bookmarks in the program
      Specified by:
      getBookmarkCount in interface BookmarkManager
      Returns:
      the total number of bookmarks in the program
    • getBookmarkCount

      public int getBookmarkCount(String type)
      Description copied from interface: BookmarkManager
      Return the number of bookmarks of the given type
      Specified by:
      getBookmarkCount in interface BookmarkManager
      Parameters:
      type - the type of bookmarks to count
      Returns:
      the number of bookmarks of the given type
    • getBookmarksIterator

      public Iterator<Bookmark> getBookmarksIterator(String type)
      Description copied from interface: BookmarkManager
      Get iterator over all bookmarks of the specified type.
      Specified by:
      getBookmarksIterator in interface BookmarkManager
      Parameters:
      type - the bookmark type to search for
      Returns:
      an iterator over all bookmarks of the specified type.
    • getBookmarksIterator

      public Iterator<Bookmark> getBookmarksIterator(Address startAddress, boolean forward)
      Description copied from interface: BookmarkManager
      Returns an iterator over all bookmark types, starting at the given address, with traversal in the given direction.
      Specified by:
      getBookmarksIterator in interface BookmarkManager
      Parameters:
      startAddress - the address at which to start
      forward - true to iterate in the forward direction; false for backwards
      Returns:
      an iterator over all bookmark types, starting at the given address, with traversal in the given direction.
    • getBookmarksIterator

      public Iterator<Bookmark> getBookmarksIterator()
      Description copied from interface: BookmarkManager
      Returns an iterator over all bookmarks
      Specified by:
      getBookmarksIterator in interface BookmarkManager
      Returns:
      an iterator over all bookmarks
    • removeBookmarks

      public void removeBookmarks(AddressSetView set, TaskMonitor monitor) throws CancelledException
      Description copied from interface: BookmarkManager
      Removes all bookmarks over the given address set.
      Specified by:
      removeBookmarks in interface BookmarkManager
      Parameters:
      set - the set of addresses from which to remove all bookmarks.
      monitor - a task monitor to report the progress.
      Throws:
      CancelledException - if the user (via the monitor) cancelled the operation.
    • removeBookmarks

      public void removeBookmarks(AddressSetView set, String type, TaskMonitor monitor) throws CancelledException
      Description copied from interface: BookmarkManager
      Removes all bookmarks of the given type over the given address set
      Specified by:
      removeBookmarks in interface BookmarkManager
      Parameters:
      set - the set of addresses from which to remove all bookmarks of the given type.
      type - the type of bookmarks to remove.
      monitor - a task monitor to report the progress.
      Throws:
      CancelledException - if the user (via the monitor) cancelled the operation.
    • removeBookmarks

      public void removeBookmarks(AddressSetView set, String type, String category, TaskMonitor monitor) throws CancelledException
      Description copied from interface: BookmarkManager
      Removes all bookmarks of the given type and category over the given address set
      Specified by:
      removeBookmarks in interface BookmarkManager
      Parameters:
      set - the set of addresses from which to remove all bookmarks of the given type and category.
      type - the type of bookmarks to remove.
      category - the category of bookmarks to remove.
      monitor - a task monitor to report the progress.
      Throws:
      CancelledException - if the user (via the monitor) cancelled the operation.
    • deleteAddressRange

      public void deleteAddressRange(Address startAddr, Address endAddr, TaskMonitor monitor) throws CancelledException
      Description copied from interface: ManagerDB
      Delete all objects which have been applied to the address range startAddr to endAddr and update the database accordingly. The specified start and end addresses must form a valid range within a single AddressSpace.
      Specified by:
      deleteAddressRange in interface ManagerDB
      Parameters:
      startAddr - the first address in the range.
      endAddr - the last address in the range.
      monitor - the task monitor to use in any upgrade operations.
      Throws:
      CancelledException - if the user cancelled the operation via the task monitor.
    • moveAddressRange

      public void moveAddressRange(Address fromAddr, Address toAddr, long length, TaskMonitor monitor) throws CancelledException
      Description copied from interface: ManagerDB
      Move all objects within an address range to a new location.
      Specified by:
      moveAddressRange in interface ManagerDB
      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 to use in any upgrade operations.
      Throws:
      CancelledException - if the user cancelled the operation via the task monitor.