View Javadoc
1   package net.sourceforge.rpgee.utility;
2   
3   public interface Observable<E> {
4   
5       /**
6        * Adds an observer to the set of observers for this object, provided that it is not the same as some observer already in the
7        * set. The order in which notifications will be delivered to multiple observers is not specified. See the class comment.
8        * 
9        * @param o an observer to be added.
10       * @throws NullPointerException if the parameter o is null.
11       */
12      public abstract void addObserver(Observer o);
13  
14      /**
15       * Deletes an observer from the set of observers of this object. Passing <CODE>null</CODE> to this method will have no effect.
16       * 
17       * @param o the observer to be deleted.
18       */
19      public abstract void deleteObserver(Observer o);
20  
21      /**
22       * If this object has changed, as indicated by the <code>hasChanged</code> method, then notify all of its observers and then
23       * call the <code>clearChanged</code> method to indicate that this object has no longer changed.
24       * <p>
25       * Each observer has its <code>update</code> method called with two arguments: this observable object and <code>null</code>.
26       * In other words, this method is equivalent to: <blockquote><tt>
27       * notifyObservers(null)</tt></blockquote>
28       * @throws Exception 
29       * 
30       * @see java.util.Observable#clearChanged()
31       * @see java.util.Observable#hasChanged()
32       * @see java.util.Observer#update(java.util.Observable, java.lang.Object)
33       */
34      public abstract void notifyObservers() throws Exception;
35  
36      /**
37       * If this object has changed, as indicated by the <code>hasChanged</code> method, then notify all of its observers and then
38       * call the <code>clearChanged</code> method to indicate that this object has no longer changed.
39       * <p>
40       * Each observer has its <code>update</code> method called with two arguments: this observable object and the <code>arg</code>
41       * argument.
42       * 
43       * @param arg any object.
44       * @throws Exception 
45       * @see java.util.Observable#clearChanged()
46       * @see java.util.Observable#hasChanged()
47       * @see java.util.Observer#update(java.util.Observable, java.lang.Object)
48       */
49      public abstract void notifyObservers(E arg) throws Exception;
50  
51      /**
52       * Clears the observer list so that this object no longer has any observers.
53       */
54      public abstract void deleteObservers();
55  
56      /**
57       * Tests if this object has changed.
58       * 
59       * @return <code>true</code> if and only if the <code>setChanged</code> method has been called more recently than the
60       *         <code>clearChanged</code> method on this object; <code>false</code> otherwise.
61       * @see java.util.Observable#clearChanged()
62       * @see java.util.Observable#setChanged()
63       */
64      public abstract boolean hasChanged();
65  
66      /**
67       * Returns the number of observers of this <tt>BaseObservable</tt> object.
68       * 
69       * @return the number of observers of this object.
70       */
71      public abstract int countObservers();
72  
73  }