Class BaseObservable

    • Constructor Detail

      • BaseObservable

        public BaseObservable​(IObservable observable)
    • Method Detail

      • addObserver

        public void addObserver​(IObserver observer)
        Description copied from interface: IObservable
        Attaches a observer to the Observable. After attachment the observer gets informed about changes in the Observable.
        Specified by:
        addObserver in interface IObservable
        Parameters:
        observer - The observer to attach to the observable
      • countObservers

        public int countObservers()
        Description copied from interface: IObservable
        Counts how many Observers were attached to this class.
        Specified by:
        countObservers in interface IObservable
        Returns:
        the number of Observers
        See Also:
        IObserver
      • getObservers

        public List<IObserver> getObservers()
        Description copied from interface: IObservable
        Returns list of observers registered with the Observable. List returned is unmodifiable list.
        Specified by:
        getObservers in interface IObservable
        Returns:
        list of observers
      • deleteObserver

        public void deleteObserver​(IObserver observer)
        Description copied from interface: IObservable
        Detaches a previously attached observer to the observable. After detachment the observer does no longer receive change notifications from the observable.
        Specified by:
        deleteObserver in interface IObservable
        Parameters:
        observer - The observer to detach from the observable
      • deleteObservers

        public void deleteObservers()
        Description copied from interface: IObservable
        Detaches all previously attached observer to the observable. After detachment observers do not longer receive change notifications from the observable.
        Specified by:
        deleteObservers in interface IObservable
      • notifyObservers

        public void notifyObservers()
        Description copied from interface: IObservable
        Notifies all attached observers about changes in the observable.
        Specified by:
        notifyObservers in interface IObservable
      • notifyObservers

        public void notifyObservers​(Object arg)
        Description copied from interface: IObservable
        Notifies all attached observers about changes in the observable.
        Specified by:
        notifyObservers in interface IObservable
        Parameters:
        arg - an arbitrary Object to be passed to the Observer
      • wrappedNotify

        protected void wrappedNotify​(IObserver observer,
                                     IObservable observable,
                                     Object arg)
        This method is intended to encapsulate the notification semantics, in order to let extended classes to implement their own version. Possible implementations are:
        • remote notification;
        • notification via SwingUtilities.invokeLater
        • others...

        The default notification simply does

         observer.update(observable, arg);
         
        Parameters:
        observer - the observer.
        observable - the object to be observed.
        arg - additional arguments.