Revision 20098 trunk/libraries/libIverUtiles/src/com/iver/utiles/exceptionHandling/ExceptionHandlingSupport.java
ExceptionHandlingSupport.java | ||
---|---|---|
43 | 43 |
import java.util.ArrayList; |
44 | 44 |
import java.util.Iterator; |
45 | 45 |
|
46 |
|
|
46 |
/** |
|
47 |
* <p>Stores a group of <code>ExceptionListener</code> that, in whatever moment |
|
48 |
* could be notified a <code>Throwable</code> Java error or exception.</p> |
|
49 |
* |
|
50 |
* <p><code>ExceptionHandlingSupport</code> is useful to manage a set of listeners |
|
51 |
* that need to be executed when a particular error or exception in a object is produced. For |
|
52 |
* instance, when user drags the mouse over a geometrical object in a view, it's possible that |
|
53 |
* some <code>ExceptionLister</code> of that object and other nearby, must be notified. Using |
|
54 |
* <code>ExceptionHandlingSupport</code> the developer can manage easily a set of that kind of |
|
55 |
* listeners, that can change according to an external factor. (In the previous sample, for intance, |
|
56 |
* can change according the closed objects to the one which this <code>ExceptionHandlingSupport</code> |
|
57 |
* refers).</p> |
|
58 |
*/ |
|
47 | 59 |
public class ExceptionHandlingSupport { |
48 |
private ArrayList exceptionListeners = new ArrayList(); |
|
60 |
/** |
|
61 |
* <p>List with a group of <code>ExceptionListener</code>.</p> |
|
62 |
*/ |
|
63 |
private ArrayList exceptionListeners = new ArrayList(); |
|
49 | 64 |
|
50 | 65 |
/** |
51 |
* A?ade un listener de las excepciones que se producen en los behavior
|
|
66 |
* <p>Adds a new <code>ExceptionListener</code> for adding support to it.</p>
|
|
52 | 67 |
* |
53 |
* @param o Listener de las excepciones
|
|
68 |
* @param o listener adapted to be notified by the <code>ExceptionHandlingSupport</code>
|
|
54 | 69 |
*/ |
55 | 70 |
public void addExceptionListener(ExceptionListener o) { |
56 | 71 |
exceptionListeners.add(o); |
57 | 72 |
} |
58 | 73 |
|
59 | 74 |
/** |
60 |
* Elimina un listener de las excepciones que se producen en los behaviours
|
|
75 |
* <p>Removes an <code>ExceptionListener</code> for finishing the support to it.</p>
|
|
61 | 76 |
* |
62 |
* @param o listener que se quiere eliminar
|
|
77 |
* @param o listener adapted to be notified by the <code>ExceptionHandlingSupport</code>
|
|
63 | 78 |
* |
64 |
* @return true si el elemento era listener de las excepciones
|
|
79 |
* @return <code>true</code> if the list contained the specified element, <code>false</code> otherwise
|
|
65 | 80 |
*/ |
66 | 81 |
public boolean removeExceptionListener(ExceptionListener o) { |
67 | 82 |
return exceptionListeners.remove(o); |
68 | 83 |
} |
69 | 84 |
|
70 | 85 |
/** |
71 |
* Notifica a los listeners de excepciones con la excepci?n o error
|
|
72 |
* que se pasa como par?metro
|
|
86 |
* <p>Notifies all registered listeners that an error or exception
|
|
87 |
* throwable by the Java Virtual Machine has been produced.</p>
|
|
73 | 88 |
* |
74 |
* @param t DOCUMENT ME!
|
|
89 |
* @param t an error or exception in the Java language
|
|
75 | 90 |
*/ |
76 | 91 |
public void throwException(Throwable t) { |
77 | 92 |
for (Iterator iter = exceptionListeners.iterator(); iter.hasNext();) { |
... | ... | |
79 | 94 |
listener.exceptionThrown(t); |
80 | 95 |
} |
81 | 96 |
} |
82 |
|
|
83 | 97 |
} |
Also available in: Unified diff