Package ghidra.program.database
Class DatabaseObject
- java.lang.Object
- 
- ghidra.program.database.DatabaseObject
 
- 
- Direct Known Subclasses:
- BookmarkDB,- EquateDB,- FunctionDB,- FunctionTagDB,- InstructionDB,- SourceArchiveDB,- SymbolDB
 
 public abstract class DatabaseObject extends java.lang.ObjectBase class for an cached object in the database. Database objects have keys. They are marked as invalid when a database cache is cleared and can be revived on a refresh as long as they haven't been deleted. Instantiating an object will cause it to be added immediately to the associated cache.
- 
- 
Field SummaryFields Modifier and Type Field Description protected longkey
 - 
Constructor SummaryConstructors Constructor Description DatabaseObject(DBObjectCache cache, long key)Constructs a new DatabaseObject and adds it to the specified cache.
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidcheckDeleted()Checks if this object has been deleted, in which case any use of the object is not allowed.booleancheckIsValid()Check whether this object is still valid.booleancheckIsValid(Record record)Check whether this object is still valid.longgetKey()Get the database key for this object.booleanisDeleted()Returns true if this object has been deleted.booleanisInvalid()Returns true if object is currently invalid.protected voidkeyChanged(long newKey)protected abstract booleanrefresh()Tells the object to refresh its state from the database.protected booleanrefresh(Record record)Tells the object to refresh its state from the database using the specified record if not null.voidsetInvalid()Invalidate this object.booleanvalidate(Lock lock)This method provides a cheap (lock free) way to test if an object is valid.
 
- 
- 
- 
Constructor Detail- 
DatabaseObjectpublic DatabaseObject(DBObjectCache cache, long key) Constructs a new DatabaseObject and adds it to the specified cache.- Parameters:
- cache- to be used for this object or null if object will not be cached
- key- database key to uniquely identify this object
 
 
- 
 - 
Method Detail- 
getKeypublic long getKey() Get the database key for this object.
 - 
isDeletedpublic boolean isDeleted() Returns true if this object has been deleted. Note: once an object has been deleted, it will never be "refreshed". For example, if an object is ever deleted and is resurrected via an "undo", you will have get a fresh instance of the object.- Returns:
- true if this object has been deleted.
 
 - 
setInvalidpublic void setInvalid() Invalidate this object. This does not necessarily mean that this object can never be used again. If the object can refresh itself, it may still be useable.
 - 
keyChangedprotected void keyChanged(long newKey) 
 - 
isInvalidpublic boolean isInvalid() Returns true if object is currently invalid. Calling checkIsValid may successfully refresh object making it valid.- See Also:
- checkIsValid()
 
 - 
checkDeletedpublic void checkDeleted() Checks if this object has been deleted, in which case any use of the object is not allowed.- Throws:
- java.util.ConcurrentModificationException- if the object has been deleted from the database.
 
 - 
checkIsValidpublic boolean checkIsValid() Check whether this object is still valid. If the object is invalid, the object will attempt to refresh itself. If the refresh fails, the object will be marked as deleted.- Returns:
- true if the object is valid.
 
 - 
checkIsValidpublic boolean checkIsValid(Record record) Check whether this object is still valid. If the object is invalid, the object will attempt to refresh itself using the specified record. If the refresh fails, the object will be marked as deleted and removed from cache. If this object is already marked as deleted, the record can not be used to refresh the object.- Parameters:
- record- optional record which may be used to refresh invalid object
- Returns:
- true if the object is valid.
 
 - 
validatepublic boolean validate(Lock lock) This method provides a cheap (lock free) way to test if an object is valid. If this object is invalid, then the lock will be used to refresh as needed.- Parameters:
- lock- the lock that will be used if the object needs to be refreshed.
- Returns:
- true if object is valid, else false
 
 - 
refreshprotected abstract boolean refresh() Tells the object to refresh its state from the database.- Returns:
- true if the object was able to refresh itself. Return false if the object was deleted. Objects that extend this class must implement a refresh method. If an object can never refresh itself, then it should always return false.
 
 - 
refreshprotected boolean refresh(Record record) Tells the object to refresh its state from the database using the specified record if not null. NOTE: The default implementation ignores the record and invokes refresh(). Implementations of this method must take care if multiple database tables are used since the record supplied could correspond to another object. In some cases it may be best not to override this method or ignore the record provided.- Parameters:
- record- valid record associated with object's key (optional, may be null to force record lookup or other refresh technique)
- Returns:
- true if the object was able to refresh itself. Return false if record is null and object was deleted. Objects that extend this class must implement a refresh method. If an object can never refresh itself, then it should always return false.
 
 
- 
 
-