Package ghidra.program.database.bookmark
Class BookmarkDBManager
- java.lang.Object
-
- ghidra.program.database.bookmark.BookmarkDBManager
-
- All Implemented Interfaces:
ErrorHandler,ManagerDB,BookmarkManager
public class BookmarkDBManager extends java.lang.Object implements BookmarkManager, ErrorHandler, ManagerDB
-
-
Field Summary
-
Fields inherited from interface ghidra.program.model.listing.BookmarkManager
OLD_BOOKMARK_PROPERTY_OBJECT_CLASS1, OLD_BOOKMARK_PROPERTY_OBJECT_CLASS2
-
-
Constructor Summary
Constructors Constructor Description BookmarkDBManager(DBHandle handle, AddressMap addrMap, int openMode, Lock lock, TaskMonitor monitor)Constructs a new CodeManager for a program.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddbError(java.io.IOException e)Notification that an IO exception occurred.BookmarkTypedefineType(java.lang.String type, javax.swing.ImageIcon icon, java.awt.Color color, int priority)Define a bookmark type with its marker icon and color.voiddeleteAddressRange(Address startAddr, Address endAddr, TaskMonitor monitor)Delete all objects which have been applied to the address range startAddr to endAddr and update the database accordingly.BookmarkgetBookmark(long id)Returns the bookmark that has the given id or null if no such bookmark exists.BookmarkgetBookmark(Address addr, java.lang.String type, java.lang.String category)Get a specific bookmarkAddressSetViewgetBookmarkAddresses(java.lang.String type)Get addresses for bookmarks of a specified type.intgetBookmarkCount()Returns the total number of bookmarks in the programintgetBookmarkCount(java.lang.String type)Return the number of bookmarks of the given typeBookmark[]getBookmarks(Address addr)Get all bookmarks on a specific addressBookmark[]getBookmarks(Address address, java.lang.String type)Get bookmarks of the indicated type on a specific addressjava.util.Iterator<Bookmark>getBookmarksIterator()Returns an iterator over all bookmarksjava.util.Iterator<Bookmark>getBookmarksIterator(Address startAddress, boolean forward)Returns an iterator over all bookmark types, starting at the given address, with traversal in the given direction.java.util.Iterator<Bookmark>getBookmarksIterator(java.lang.String type)Get iterator over all bookmarks of the specified type.BookmarkTypegetBookmarkType(java.lang.String type)Get a bookmark typeBookmarkType[]getBookmarkTypes()Returns list of known bookmark typesjava.lang.String[]getCategories(java.lang.String type)Get list of categories used for a specified typeProgramgetProgram()Returns the program associated with this BookmarkManager.booleanhasBookmarks(java.lang.String type)Returns true if program contains one or more bookmarks of the given typevoidinvalidateCache(boolean all)Invalidate cached objects held by this manager.voidmoveAddressRange(Address fromAddr, Address toAddr, long length, TaskMonitor monitor)Move all objects within an address range to a new location.voidprogramReady(int openMode, int currentRevision, TaskMonitor monitor)Callback from program made to each manager after the program has completed initialization.voidremoveBookmark(Bookmark bookmark)Remove bookmarkvoidremoveBookmarks(AddressSetView set, TaskMonitor monitor)Removes all bookmarks over the given address set.voidremoveBookmarks(AddressSetView set, java.lang.String type, TaskMonitor monitor)Removes all bookmarks of the given type over the given address setvoidremoveBookmarks(AddressSetView set, java.lang.String type, java.lang.String category, TaskMonitor monitor)Removes all bookmarks of the given type and category over the given address setvoidremoveBookmarks(java.lang.String type)Removes all bookmarks of the given type.voidremoveBookmarks(java.lang.String type, java.lang.String category, TaskMonitor monitor)Removes all bookmarks with the given type and category.BookmarksetBookmark(Address addr, java.lang.String type, java.lang.String category, java.lang.String comment)Set a bookmark.voidsetProgram(ProgramDB program)Callback from program used to indicate all manager have been created.
-
-
-
Constructor Detail
-
BookmarkDBManager
public BookmarkDBManager(DBHandle handle, AddressMap addrMap, int openMode, Lock lock, TaskMonitor monitor) throws VersionException, java.io.IOException
Constructs a new CodeManager for a program.- Parameters:
handle- handle to databaseaddrMap- addressMap to convert between addresses and long values.openMode- either READ_ONLY, UPDATE, or UPGRADElock- the program synchronization lockmonitor- the task monitor use while upgrading.- Throws:
VersionException- if the database is incompatible with the current schemajava.io.IOException- if there is a problem accessing the database.
-
-
Method Detail
-
setProgram
public void setProgram(ProgramDB program)
Description copied from interface:ManagerDBCallback 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:
setProgramin interfaceManagerDB- Parameters:
program- the program is set when all the initializations have been completed.
-
programReady
public void programReady(int openMode, int currentRevision, TaskMonitor monitor) throws java.io.IOException, CancelledExceptionDescription copied from interface:ManagerDBCallback 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:
programReadyin interfaceManagerDB- 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:
java.io.IOException- if a database io error occurs.CancelledException- if the user cancelled the operation via the task monitor.
-
dbError
public void dbError(java.io.IOException e)
Description copied from interface:ErrorHandlerNotification that an IO exception occurred.- Specified by:
dbErrorin interfaceErrorHandler
-
invalidateCache
public void invalidateCache(boolean all)
Invalidate cached objects held by this manager.- Specified by:
invalidateCachein interfaceManagerDB- 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(java.lang.String type, javax.swing.ImageIcon icon, java.awt.Color color, int priority)
Description copied from interface:BookmarkManagerDefine 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:
defineTypein interfaceBookmarkManager- Parameters:
type- bookmark typeicon- marker icon which may get scaledcolor- marker colorpriority- the bookmark priority- Returns:
- bookmark type object
-
getBookmarkTypes
public BookmarkType[] getBookmarkTypes()
Description copied from interface:BookmarkManagerReturns list of known bookmark types- Specified by:
getBookmarkTypesin interfaceBookmarkManager- Returns:
- list of known bookmark types
-
getProgram
public Program getProgram()
Description copied from interface:BookmarkManagerReturns the program associated with this BookmarkManager.- Specified by:
getProgramin interfaceBookmarkManager- Returns:
- the program associated with this BookmarkManager.
-
getBookmarkType
public BookmarkType getBookmarkType(java.lang.String type)
Description copied from interface:BookmarkManagerGet a bookmark type- Specified by:
getBookmarkTypein interfaceBookmarkManager- Parameters:
type- bookmark type name- Returns:
- bookmark type or null if type is unknown
-
setBookmark
public Bookmark setBookmark(Address addr, java.lang.String type, java.lang.String category, java.lang.String comment)
Description copied from interface:BookmarkManagerSet a bookmark.- Specified by:
setBookmarkin interfaceBookmarkManager- Parameters:
addr- the address at which to set a bookmarktype- 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, java.lang.String type, java.lang.String category)
Description copied from interface:BookmarkManagerGet a specific bookmark- Specified by:
getBookmarkin interfaceBookmarkManager- Parameters:
addr- the address of the bookmark to retrievetype- 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:BookmarkManagerRemove bookmark- Specified by:
removeBookmarkin interfaceBookmarkManager- Parameters:
bookmark- the bookmark to remove.
-
removeBookmarks
public void removeBookmarks(java.lang.String type)
Description copied from interface:BookmarkManagerRemoves all bookmarks of the given type.- Specified by:
removeBookmarksin interfaceBookmarkManager- Parameters:
type- bookmark type
-
removeBookmarks
public void removeBookmarks(java.lang.String type, java.lang.String category, TaskMonitor monitor) throws CancelledExceptionDescription copied from interface:BookmarkManagerRemoves all bookmarks with the given type and category.- Specified by:
removeBookmarksin interfaceBookmarkManager- 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:BookmarkManagerGet all bookmarks on a specific address- Specified by:
getBookmarksin interfaceBookmarkManager- Parameters:
addr- the address at which to retrieve all bookmarks.- Returns:
- array of bookmarks
-
getBookmarks
public Bookmark[] getBookmarks(Address address, java.lang.String type)
Description copied from interface:BookmarkManagerGet bookmarks of the indicated type on a specific address- Specified by:
getBookmarksin interfaceBookmarkManager- Parameters:
address- the address at which to search for bookmarks.type- bookmark type to search for- Returns:
- array of bookmarks
-
hasBookmarks
public boolean hasBookmarks(java.lang.String type)
Description copied from interface:BookmarkManagerReturns true if program contains one or more bookmarks of the given type- Specified by:
hasBookmarksin interfaceBookmarkManager- Parameters:
type- the type of bookmark to check for.- Returns:
- true if program contains one or more bookmarks of the given type
-
getCategories
public java.lang.String[] getCategories(java.lang.String type)
Description copied from interface:BookmarkManagerGet list of categories used for a specified type- Specified by:
getCategoriesin interfaceBookmarkManager- Parameters:
type- bookmark type- Returns:
- array of category strings
-
getBookmarkAddresses
public AddressSetView getBookmarkAddresses(java.lang.String type)
Description copied from interface:BookmarkManagerGet addresses for bookmarks of a specified type.- Specified by:
getBookmarkAddressesin interfaceBookmarkManager- Parameters:
type- bookmark type- Returns:
- address set containing bookmarks of the specified type.
-
getBookmark
public Bookmark getBookmark(long id)
Description copied from interface:BookmarkManagerReturns the bookmark that has the given id or null if no such bookmark exists.- Specified by:
getBookmarkin interfaceBookmarkManager- Parameters:
id- the id of the bookmark to be retrieved.- Returns:
- the bookmark
-
getBookmarkCount
public int getBookmarkCount()
Description copied from interface:BookmarkManagerReturns the total number of bookmarks in the program- Specified by:
getBookmarkCountin interfaceBookmarkManager- Returns:
- the total number of bookmarks in the program
-
getBookmarkCount
public int getBookmarkCount(java.lang.String type)
Description copied from interface:BookmarkManagerReturn the number of bookmarks of the given type- Specified by:
getBookmarkCountin interfaceBookmarkManager- Parameters:
type- the type of bookmarks to count- Returns:
- the number of bookmarks of the given type
-
getBookmarksIterator
public java.util.Iterator<Bookmark> getBookmarksIterator(java.lang.String type)
Description copied from interface:BookmarkManagerGet iterator over all bookmarks of the specified type.- Specified by:
getBookmarksIteratorin interfaceBookmarkManager- Parameters:
type- the bookmark type to search for- Returns:
- an iterator over all bookmarks of the specified type.
-
getBookmarksIterator
public java.util.Iterator<Bookmark> getBookmarksIterator(Address startAddress, boolean forward)
Description copied from interface:BookmarkManagerReturns an iterator over all bookmark types, starting at the given address, with traversal in the given direction.- Specified by:
getBookmarksIteratorin interfaceBookmarkManager- Parameters:
startAddress- the address at which to startforward- 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 java.util.Iterator<Bookmark> getBookmarksIterator()
Description copied from interface:BookmarkManagerReturns an iterator over all bookmarks- Specified by:
getBookmarksIteratorin interfaceBookmarkManager- Returns:
- an iterator over all bookmarks
-
removeBookmarks
public void removeBookmarks(AddressSetView set, TaskMonitor monitor) throws CancelledException
Description copied from interface:BookmarkManagerRemoves all bookmarks over the given address set.- Specified by:
removeBookmarksin interfaceBookmarkManager- 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, java.lang.String type, TaskMonitor monitor) throws CancelledException
Description copied from interface:BookmarkManagerRemoves all bookmarks of the given type over the given address set- Specified by:
removeBookmarksin interfaceBookmarkManager- 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, java.lang.String type, java.lang.String category, TaskMonitor monitor) throws CancelledException
Description copied from interface:BookmarkManagerRemoves all bookmarks of the given type and category over the given address set- Specified by:
removeBookmarksin interfaceBookmarkManager- 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:ManagerDBDelete all objects which have been applied to the address range startAddr to endAddr and update the database accordingly.- Specified by:
deleteAddressRangein interfaceManagerDB- 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:ManagerDBMove all objects within an address range to a new location.- Specified by:
moveAddressRangein interfaceManagerDB- 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.
-
-