Class DomainObjectAdapter

  • All Implemented Interfaces:
    DomainObject
    Direct Known Subclasses:
    DomainObjectAdapterDB

    public abstract class DomainObjectAdapter
    extends java.lang.Object
    implements DomainObject
    An abstract class that provides default behavior for DomainObject(s), specifically it handles listeners and change status; the derived class must provide the getDescription() method.
    • Field Detail

      • name

        protected java.lang.String name
      • changeSupportMap

        protected java.util.Map<EventQueueID,​ghidra.framework.data.DomainObjectChangeSupport> changeSupportMap
      • metadata

        protected java.util.Map<java.lang.String,​java.lang.String> metadata
      • changed

        protected boolean changed
      • temporary

        protected boolean temporary
      • lock

        protected Lock lock
    • Constructor Detail

      • DomainObjectAdapter

        protected DomainObjectAdapter​(java.lang.String name,
                                      int timeInterval,
                                      int bufsize,
                                      java.lang.Object consumer)
        Construct a new DomainObjectAdapter. If construction of this object fails, be sure to release with consumer.
        Parameters:
        name - name of the object
        timeInterval - the time (in milliseconds) to wait before the event queue is flushed. If a new event comes in before the time expires, the timer is reset.
        bufsize - initial size of event buffer
        consumer - the object that created this domain object
    • Method Detail

      • release

        public void release​(java.lang.Object consumer)
        Description copied from interface: DomainObject
        Notify the domain object that the specified consumer is no longer using it. When the last consumer invokes this method, the domain object will be closed and will become invalid.
        Specified by:
        release in interface DomainObject
        Parameters:
        consumer - the consumer (e.g., tool, plugin, etc) of the domain object previously established with the addConsumer method.
        See Also:
        DomainObject.release(java.lang.Object)
      • getLock

        public Lock getLock()
      • getAssociatedUserFilesystem

        protected FileSystem getAssociatedUserFilesystem()
        Returns the hidden user-filesystem associated with this objects domain file, or null if unknown.
        Returns:
        user data file system
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        See Also:
        Object.toString()
      • setTemporary

        public void setTemporary​(boolean state)
        Description copied from interface: DomainObject
        Set the temporary state of this object. If this object is temporary, the isChanged() method will always return false. The default temporary state is false.
        Specified by:
        setTemporary in interface DomainObject
        Parameters:
        state - if true object is marked as temporary
        See Also:
        DomainObject.setTemporary(boolean)
      • setDomainFile

        protected void setDomainFile​(DomainFile df)
      • close

        protected void close()
      • getChangeStatus

        public boolean getChangeStatus()
        Return "changed" status
        Returns:
        true if this object has changed
      • addCloseListener

        public void addCloseListener​(DomainObjectClosedListener listener)
        Description copied from interface: DomainObject
        Adds a listener that will be notified when this DomainObject is closed. This is meant for clients to have a chance to cleanup, such as reference removal.
        Specified by:
        addCloseListener in interface DomainObject
        Parameters:
        listener - the reference to add
      • createPrivateEventQueue

        public EventQueueID createPrivateEventQueue​(DomainObjectListener listener,
                                                    int maxDelay)
        Description copied from interface: DomainObject
        Creates a private event queue that can be flushed independently from the main event queue.
        Specified by:
        createPrivateEventQueue in interface DomainObject
        Parameters:
        listener - the listener to be notified of domain object events.
        maxDelay - the time interval (in milliseconds) used to buffer events.
        Returns:
        a unique identifier for this private queue.
      • removePrivateEventQueue

        public boolean removePrivateEventQueue​(EventQueueID id)
        Description copied from interface: DomainObject
        Removes the specified private event queue
        Specified by:
        removePrivateEventQueue in interface DomainObject
        Parameters:
        id - the id of the queue to remove.
        Returns:
        true if the id represents a valid queue that was removed.
      • flushPrivateEventQueue

        public void flushPrivateEventQueue​(EventQueueID id)
        Description copied from interface: DomainObject
        Flush events from the specified event queue.
        Specified by:
        flushPrivateEventQueue in interface DomainObject
        Parameters:
        id - the id specifying the event queue to be flushed.
      • fireEvent

        public void fireEvent​(DomainObjectChangeRecord ev)
        Fires the specified event.
        Parameters:
        ev - event to fire
      • setEventsEnabled

        public void setEventsEnabled​(boolean v)
        Description copied from interface: DomainObject
        If true, domain object change events are sent. If false, no events are sent.

        NOTE: disabling events could cause plugins to be out of sync!

        NOTE: when re-enabling events, an event will be sent to the system to signal that every listener should update.

        Specified by:
        setEventsEnabled in interface DomainObject
        Parameters:
        v - true means to enable events
        See Also:
        DomainObject.setEventsEnabled(boolean)
      • hasExclusiveAccess

        public boolean hasExclusiveAccess()
        Description copied from interface: DomainObject
        Returns true if the user has exclusive access to the domain object. Exclusive access means either the object is not shared or the user has an exclusive checkout on the object.
        Specified by:
        hasExclusiveAccess in interface DomainObject
        See Also:
        DomainObject.hasExclusiveAccess()
      • setChanged

        protected void setChanged​(boolean state)
      • addConsumer

        public boolean addConsumer​(java.lang.Object consumer)
        Description copied from interface: DomainObject
        Adds the given object as a consumer. The release method must be invoked with this same consumer instance when this domain object is no longer in-use.
        Specified by:
        addConsumer in interface DomainObject
        Parameters:
        consumer - domain object consumer
        Returns:
        false if this domain object has already been closed
        See Also:
        DomainObject.addConsumer(java.lang.Object)
      • isUsedBy

        public boolean isUsedBy​(java.lang.Object consumer)
        Returns true if the given tool is using this object.
        Specified by:
        isUsedBy in interface DomainObject
        Parameters:
        consumer - the object to test to see if it is a consumer of this domain object.
        Returns:
        true if the given consumer is using (has open) this domain object;
      • getConsumerList

        public java.util.ArrayList<java.lang.Object> getConsumerList()
        Description copied from interface: DomainObject
        Returns the list of consumers on this domainObject
        Specified by:
        getConsumerList in interface DomainObject
        Returns:
        the list of consumers.
      • setDefaultContentClass

        public static void setDefaultContentClass​(java.lang.Class<?> doClass)
        Set default content type
        Parameters:
        doClass - default domain object implementation
      • getContentHandler

        public static ContentHandler getContentHandler​(DomainObject dobj)
                                                throws java.io.IOException
        Get the ContentHandler associated with the specified domain object
        Parameters:
        dobj - domain object
        Returns:
        content handler
        Throws:
        java.io.IOException
      • getMetadata

        public java.util.Map<java.lang.String,​java.lang.String> getMetadata()
        Description copied from interface: DomainObject
        Returns a map containing all the stored metadata associated with this domain object. The map contains key,value pairs and are ordered by their insertion order.
        Specified by:
        getMetadata in interface DomainObject
        Returns:
        a map containing all the stored metadata associated with this domain object.
      • getModificationNumber

        public long getModificationNumber()
        Description copied from interface: DomainObject
        Returns a long value that gets incremented every time a change, undo, or redo takes place. Useful for implementing a lazy caching system.
        Specified by:
        getModificationNumber in interface DomainObject
        Returns:
        a long value that is incremented for every change to the program.
      • fatalErrorOccurred

        protected void fatalErrorOccurred​(java.lang.Exception e)