|
| 1 | +/* |
| 2 | + * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | + * |
| 5 | + * This code is free software; you can redistribute it and/or modify it |
| 6 | + * under the terms of the GNU General Public License version 2 only, as |
| 7 | + * published by the Free Software Foundation. Oracle designates this |
| 8 | + * particular file as subject to the "Classpath" exception as provided |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. |
| 10 | + * |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that |
| 15 | + * accompanied this code). |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU General Public License version |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | + * |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 22 | + * or visit www.oracle.com if you need additional information or have any |
| 23 | + * questions. |
| 24 | + */ |
| 25 | + |
| 26 | +package java.beans; |
| 27 | + |
| 28 | +import java.util.EventListenerProxy; |
| 29 | + |
| 30 | +/** |
| 31 | + * A class which extends the <code>EventListenerProxy</code> specifically |
| 32 | + * for associating a <code>VetoableChangeListener</code> with a "constrained" |
| 33 | + * property. Instances of this class can be added as a |
| 34 | + * <code>VetoableChangeListener</code> to a bean which supports firing |
| 35 | + * VetoableChange events. |
| 36 | + * <p> |
| 37 | + * If the object has a <code>getVetoableChangeListeners()</code> |
| 38 | + * method then the array returned could be a mixture of |
| 39 | + * <code>VetoableChangeListener</code> and |
| 40 | + * <code>VetoableChangeListenerProxy</code> objects. |
| 41 | + * <p> |
| 42 | + * @see java.util.EventListenerProxy |
| 43 | + * @see VetoableChangeListener |
| 44 | + * @see VetoableChangeSupport#getVetoableChangeListeners |
| 45 | + * @since 1.4 |
| 46 | + */ |
| 47 | +public class VetoableChangeListenerProxy extends EventListenerProxy |
| 48 | + implements VetoableChangeListener { |
| 49 | + |
| 50 | + private String propertyName; |
| 51 | + |
| 52 | + /** |
| 53 | + * @param propertyName The name of the property to listen on. |
| 54 | + * @param listener The listener object |
| 55 | + */ |
| 56 | + public VetoableChangeListenerProxy(String propertyName, |
| 57 | + VetoableChangeListener listener) { |
| 58 | + super(listener); |
| 59 | + this.propertyName = propertyName; |
| 60 | + } |
| 61 | + |
| 62 | + /** |
| 63 | + * Forwards the property change event to the listener delegate. |
| 64 | + * |
| 65 | + * @param evt the property change event |
| 66 | + * |
| 67 | + * @exception PropertyVetoException if the recipient wishes the property |
| 68 | + * change to be rolled back. |
| 69 | + */ |
| 70 | + public void vetoableChange(PropertyChangeEvent evt) throws |
| 71 | + PropertyVetoException{ |
| 72 | + ((VetoableChangeListener)getListener()).vetoableChange(evt); |
| 73 | + } |
| 74 | + |
| 75 | + /** |
| 76 | + * Returns the name of the named property associated with the |
| 77 | + * listener. |
| 78 | + */ |
| 79 | + public String getPropertyName() { |
| 80 | + return propertyName; |
| 81 | + } |
| 82 | +} |
0 commit comments