home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / main.bin / PropertyChangeEvent.java < prev    next >
Text File  |  1997-05-20  |  4KB  |  110 lines

  1. /*
  2.  * @(#)PropertyChangeEvent.java    1.21 97/01/03  
  3.  * 
  4.  * Copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  * CopyrightVersion bdk_beta
  20.  * 
  21.  */
  22.  
  23. package java.beans;
  24.  
  25. /**
  26.  * A "PropertyChange" event gets delivered whenever a bean changes a "bound"
  27.  * or "constrained" property.  A PropertyChangeEvent object is sent as an
  28.  * argument to the PropertyChangeListener and VetoableChangeListener methods.
  29.  * <P>
  30.  * Normally PropertyChangeEvents are accompanied by the name and the old
  31.  * and new value of the changed property.  If the new value is a builtin
  32.  * type (such as int or boolean) it must be wrapped as the 
  33.  * corresponding java.lang.* Object type (such as Integer or Boolean).
  34.  * <P>
  35.  * Null values may be provided for the old and the new values if their
  36.  * true values are not known.
  37.  * <P>
  38.  * An event source may send a null object as the name to indicate that an
  39.  * arbitrary set of if its properties have changed.  In this case the
  40.  * old and new values should also be null.
  41.  */
  42.  
  43. public class PropertyChangeEvent extends java.util.EventObject {
  44.  
  45.     /**
  46.      * @param source  The bean that fired the event.
  47.      * @param propertyName  The programmatic name of the property
  48.      *        that was changed.
  49.      * @param oldValue  The old value of the property.
  50.      * @param newValue  The new value of the property.
  51.      */
  52.     public PropertyChangeEvent(Object source, String propertyName,
  53.                      Object oldValue, Object newValue) {
  54.     super(source);
  55.     this.propertyName = propertyName;
  56.     this.newValue = newValue;
  57.     this.oldValue = oldValue;
  58.     }
  59.  
  60.     /**
  61.      * @return  The programmatic name of the property that was changed.
  62.      *        May be null if multiple properties have changed.
  63.      */
  64.     public String getPropertyName() {
  65.     return propertyName;
  66.     }
  67.     
  68.     /**
  69.      * @return  The new value for the property, expressed as an Object.
  70.      *        May be null if multiple properties have changed.
  71.      */
  72.     public Object getNewValue() {
  73.     return newValue;
  74.     }
  75.  
  76.     /**
  77.      * @return  The old value for the property, expressed as an Object.
  78.      *        May be null if multiple properties have changed.
  79.      */
  80.     public Object getOldValue() {
  81.     return oldValue;
  82.     }
  83.  
  84.     /**
  85.      * @param propagationId  The propagationId object for the event.
  86.      */
  87.     public void setPropagationId(Object propagationId) {
  88.     this.propagationId = propagationId;
  89.     }
  90.  
  91.     /**
  92.      * The "propagationId" field is reserved for future use.  In Beans 1.0
  93.      * the sole requirement is that if a listener catches a PropertyChangeEvent
  94.      * and then fires a PropertyChangeEvent of its own, then it should
  95.      * make sure that it propagates the propagationId field from its
  96.      * incoming event to its outgoing event.
  97.      *
  98.      * @return the propagationId object associated with a bound/constrained
  99.      *        property update.
  100.      */
  101.     public Object getPropagationId() {
  102.     return propagationId;
  103.     }
  104.  
  105.     private String propertyName;
  106.     private Object newValue;
  107.     private Object oldValue;
  108.     private Object propagationId;
  109. }
  110.