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. package java.beans;
  8. import java.util.EventListenerProxy;
  9. /**
  10. * A class which extends the <code>EventListenerProxy</code> specifically
  11. * for associating a <code>VetoableChangeListener</code> with a "constrained"
  12. * property. Instances of this class can be added as a
  13. * <code>VetoableChangeListener</code> to a bean which supports firing
  14. * VetoableChange events.
  15. * <p>
  16. * If the object has a <code>getVetoableChangeListeners()</code>
  17. * method then the array returned could be a mixture of
  18. * <code>VetoableChangeListener</code> and
  19. * <code>VetoableChangeListenerProxy</code> objects.
  20. * <p>
  21. * @see java.util.EventListenerProxy
  22. * @see VetoableChangeListener
  23. * @see VetoableChangeSupport#getVetoableChangeListeners
  24. * @since 1.4
  25. */
  26. public class VetoableChangeListenerProxy extends EventListenerProxy
  27. implements VetoableChangeListener {
  28. private String propertyName;
  29. /**
  30. * @param propertyName The name of the property to listen on.
  31. * @param listener The listener object
  32. */
  33. public VetoableChangeListenerProxy(String propertyName,
  34. VetoableChangeListener listener) {
  35. super(listener);
  36. this.propertyName = propertyName;
  37. }
  38. /**
  39. * Forwards the property change event to the listener delegate.
  40. *
  41. * @param evt the property change event
  42. *
  43. * @exception PropertyVetoException if the recipient wishes the property
  44. * change to be rolled back.
  45. */
  46. public void vetoableChange(PropertyChangeEvent evt) throws
  47. PropertyVetoException{
  48. ((VetoableChangeListener)getListener()).vetoableChange(evt);
  49. }
  50. /**
  51. * Returns the name of the named property associated with the
  52. * listener.
  53. */
  54. public String getPropertyName() {
  55. return propertyName;
  56. }
  57. }