KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > beans > VetoableChangeListenerProxy


1 /*
2  * @(#)VetoableChangeListenerProxy.java 1.6 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.beans;
9
10 import java.util.EventListenerProxy JavaDoc;
11
12 /**
13  * A class which extends the <code>EventListenerProxy</code> specifically
14  * for associating a <code>VetoableChangeListener</code> with a "constrained"
15  * property. Instances of this class can be added as a
16  * <code>VetoableChangeListener</code> to a bean which supports firing
17  * VetoableChange events.
18  * <p>
19  * If the object has a <code>getVetoableChangeListeners()</code>
20  * method then the array returned could be a mixture of
21  * <code>VetoableChangeListener</code> and
22  * <code>VetoableChangeListenerProxy</code> objects.
23  * <p>
24  * @see java.util.EventListenerProxy
25  * @see VetoableChangeListener
26  * @see VetoableChangeSupport#getVetoableChangeListeners
27  * @since 1.4
28  */

29 public class VetoableChangeListenerProxy extends EventListenerProxy JavaDoc
30         implements VetoableChangeListener JavaDoc {
31     
32     private String JavaDoc propertyName;
33
34     /**
35     * @param propertyName The name of the property to listen on.
36     * @param listener The listener object
37     */

38     public VetoableChangeListenerProxy(String JavaDoc propertyName,
39             VetoableChangeListener JavaDoc listener) {
40         super(listener);
41         this.propertyName = propertyName;
42     }
43
44     /**
45     * Forwards the property change event to the listener delegate.
46     *
47     * @param evt the property change event
48     *
49     * @exception PropertyVetoException if the recipient wishes the property
50     * change to be rolled back.
51     */

52     public void vetoableChange(PropertyChangeEvent JavaDoc evt) throws
53             PropertyVetoException JavaDoc{
54         ((VetoableChangeListener JavaDoc)getListener()).vetoableChange(evt);
55     }
56
57     /**
58     * Returns the name of the named property associated with the
59     * listener.
60     */

61     public String JavaDoc getPropertyName() {
62         return propertyName;
63     }
64 }
65
Popular Tags