0N/A/*
2362N/A * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage java.beans;
0N/A
0N/A/**
0N/A * A "PropertyChange" event gets delivered whenever a bean changes a "bound"
0N/A * or "constrained" property. A PropertyChangeEvent object is sent as an
0N/A * argument to the PropertyChangeListener and VetoableChangeListener methods.
0N/A * <P>
0N/A * Normally PropertyChangeEvents are accompanied by the name and the old
0N/A * and new value of the changed property. If the new value is a primitive
0N/A * type (such as int or boolean) it must be wrapped as the
0N/A * corresponding java.lang.* Object type (such as Integer or Boolean).
0N/A * <P>
0N/A * Null values may be provided for the old and the new values if their
0N/A * true values are not known.
0N/A * <P>
0N/A * An event source may send a null object as the name to indicate that an
0N/A * arbitrary set of if its properties have changed. In this case the
0N/A * old and new values should also be null.
0N/A */
0N/A
0N/Apublic class PropertyChangeEvent extends java.util.EventObject {
1076N/A private static final long serialVersionUID = 7042693688939648123L;
0N/A
0N/A /**
0N/A * Constructs a new <code>PropertyChangeEvent</code>.
0N/A *
0N/A * @param source The bean that fired the event.
0N/A * @param propertyName The programmatic name of the property
0N/A * that was changed.
0N/A * @param oldValue The old value of the property.
0N/A * @param newValue The new value of the property.
0N/A */
0N/A public PropertyChangeEvent(Object source, String propertyName,
0N/A Object oldValue, Object newValue) {
0N/A super(source);
0N/A this.propertyName = propertyName;
0N/A this.newValue = newValue;
0N/A this.oldValue = oldValue;
0N/A }
0N/A
0N/A /**
0N/A * Gets the programmatic name of the property that was changed.
0N/A *
0N/A * @return The programmatic name of the property that was changed.
0N/A * May be null if multiple properties have changed.
0N/A */
0N/A public String getPropertyName() {
0N/A return propertyName;
0N/A }
0N/A
0N/A /**
0N/A * Gets the new value for the property, expressed as an Object.
0N/A *
0N/A * @return The new value for the property, expressed as an Object.
0N/A * May be null if multiple properties have changed.
0N/A */
0N/A public Object getNewValue() {
0N/A return newValue;
0N/A }
0N/A
0N/A /**
0N/A * Gets the old value for the property, expressed as an Object.
0N/A *
0N/A * @return The old value for the property, expressed as an Object.
0N/A * May be null if multiple properties have changed.
0N/A */
0N/A public Object getOldValue() {
0N/A return oldValue;
0N/A }
0N/A
0N/A /**
0N/A * Sets the propagationId object for the event.
0N/A *
0N/A * @param propagationId The propagationId object for the event.
0N/A */
0N/A public void setPropagationId(Object propagationId) {
0N/A this.propagationId = propagationId;
0N/A }
0N/A
0N/A /**
0N/A * The "propagationId" field is reserved for future use. In Beans 1.0
0N/A * the sole requirement is that if a listener catches a PropertyChangeEvent
0N/A * and then fires a PropertyChangeEvent of its own, then it should
0N/A * make sure that it propagates the propagationId field from its
0N/A * incoming event to its outgoing event.
0N/A *
0N/A * @return the propagationId object associated with a bound/constrained
0N/A * property update.
0N/A */
0N/A public Object getPropagationId() {
0N/A return propagationId;
0N/A }
0N/A
0N/A /**
0N/A * name of the property that changed. May be null, if not known.
0N/A * @serial
0N/A */
0N/A private String propertyName;
0N/A
0N/A /**
0N/A * New value for property. May be null if not known.
0N/A * @serial
0N/A */
0N/A private Object newValue;
0N/A
0N/A /**
0N/A * Previous value for property. May be null if not known.
0N/A * @serial
0N/A */
0N/A private Object oldValue;
0N/A
0N/A /**
0N/A * Propagation ID. May be null.
0N/A * @serial
0N/A * @see #getPropagationId
0N/A */
0N/A private Object propagationId;
2172N/A
2172N/A /**
2172N/A * Returns a string representation of the object.
2172N/A *
2172N/A * @return a string representation of the object
2172N/A *
2172N/A * @since 1.7
2172N/A */
2172N/A public String toString() {
2172N/A StringBuilder sb = new StringBuilder(getClass().getName());
2172N/A sb.append("[propertyName=").append(getPropertyName());
2172N/A appendTo(sb);
2172N/A sb.append("; oldValue=").append(getOldValue());
2172N/A sb.append("; newValue=").append(getNewValue());
2172N/A sb.append("; propagationId=").append(getPropagationId());
2172N/A sb.append("; source=").append(getSource());
2172N/A return sb.append("]").toString();
2172N/A }
2172N/A
2172N/A void appendTo(StringBuilder sb) {
2172N/A }
0N/A}