1/* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18package java.beans; 19 20import java.util.EventObject; 21 22/** 23 * An event that indicates that a constraint or a boundary of a property has 24 * changed. 25 * 26 * @since Android 1.0 27 */ 28public class PropertyChangeEvent extends EventObject { 29 30 private static final long serialVersionUID = 7042693688939648123L; 31 32 String propertyName; 33 34 Object oldValue; 35 36 Object newValue; 37 38 Object propagationId; 39 40 /** 41 * The constructor used to create a new {@code PropertyChangeEvent}. 42 * 43 * @param source 44 * the changed bean. 45 * @param propertyName 46 * the changed property, or <code>null</code> to indicate an 47 * unspecified set of the properties has changed. 48 * @param oldValue 49 * the previous value of the property, or <code>null</code> if 50 * the <code>propertyName</code> is <code>null</code> or the 51 * previous value is unknown. 52 * @param newValue 53 * the new value of the property, or <code>null</code> if the 54 * <code>propertyName</code> is <code>null</code> or the new 55 * value is unknown. 56 */ 57 public PropertyChangeEvent(Object source, String propertyName, 58 Object oldValue, Object newValue) { 59 super(source); 60 61 this.propertyName = propertyName; 62 this.oldValue = oldValue; 63 this.newValue = newValue; 64 } 65 66 /** 67 * Returns the name of the property that has changed. If an unspecified set 68 * of properties has changed it returns null. 69 * 70 * @return the name of the property that has changed, or null. 71 */ 72 public String getPropertyName() { 73 return propertyName; 74 } 75 76 /** 77 * Sets the propagationId object. 78 * 79 * @see #getPropagationId() 80 */ 81 public void setPropagationId(Object propagationId) { 82 this.propagationId = propagationId; 83 } 84 85 /** 86 * Returns the propagationId object. This is reserved for future use. Beans 87 * 1.0 demands that a listener receiving this property and then sending its 88 * own PropertyChangeEvent sets the received propagationId on the new 89 * PropertyChangeEvent's propagationId field. 90 * 91 * @return the propagationId object. 92 */ 93 public Object getPropagationId() { 94 return propagationId; 95 } 96 97 /** 98 * Returns the old value that the property had. If the old value is unknown 99 * this method returns null. 100 * 101 * @return the old property value or null. 102 */ 103 public Object getOldValue() { 104 return oldValue; 105 } 106 107 /** 108 * Returns the new value that the property now has. If the new value is 109 * unknown this method returns null. 110 * 111 * @return the old property value or null. 112 */ 113 public Object getNewValue() { 114 return newValue; 115 } 116} 117