jaroslav@601: /*
jaroslav@601: * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
jaroslav@601: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jaroslav@601: *
jaroslav@601: * This code is free software; you can redistribute it and/or modify it
jaroslav@601: * under the terms of the GNU General Public License version 2 only, as
jaroslav@601: * published by the Free Software Foundation. Oracle designates this
jaroslav@601: * particular file as subject to the "Classpath" exception as provided
jaroslav@601: * by Oracle in the LICENSE file that accompanied this code.
jaroslav@601: *
jaroslav@601: * This code is distributed in the hope that it will be useful, but WITHOUT
jaroslav@601: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jaroslav@601: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jaroslav@601: * version 2 for more details (a copy is included in the LICENSE file that
jaroslav@601: * accompanied this code).
jaroslav@601: *
jaroslav@601: * You should have received a copy of the GNU General Public License version
jaroslav@601: * 2 along with this work; if not, write to the Free Software Foundation,
jaroslav@601: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jaroslav@601: *
jaroslav@601: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
jaroslav@601: * or visit www.oracle.com if you need additional information or have any
jaroslav@601: * questions.
jaroslav@601: */
jaroslav@601: package java.beans;
jaroslav@601:
jaroslav@601: /**
jaroslav@601: * An "IndexedPropertyChange" event gets delivered whenever a component that
jaroslav@601: * conforms to the JavaBeans™ specification (a "bean") changes a bound
jaroslav@601: * indexed property. This class is an extension of PropertyChangeEvent
jaroslav@601: * but contains the index of the property that has changed.
jaroslav@601: *
jaroslav@601: * Null values may be provided for the old and the new values if their jaroslav@601: * true values are not known. jaroslav@601: *
jaroslav@601: * An event source may send a null object as the name to indicate that an
jaroslav@601: * arbitrary set of if its properties have changed. In this case the
jaroslav@601: * old and new values should also be null.
jaroslav@601: *
jaroslav@601: * @since 1.5
jaroslav@601: * @author Mark Davidson
jaroslav@601: */
jaroslav@601: public class IndexedPropertyChangeEvent extends PropertyChangeEvent {
jaroslav@601: private static final long serialVersionUID = -320227448495806870L;
jaroslav@601:
jaroslav@601: private int index;
jaroslav@601:
jaroslav@601: /**
jaroslav@601: * Constructs a new IndexedPropertyChangeEvent
object.
jaroslav@601: *
jaroslav@601: * @param source The bean that fired the event.
jaroslav@601: * @param propertyName The programmatic name of the property that
jaroslav@601: * was changed.
jaroslav@601: * @param oldValue The old value of the property.
jaroslav@601: * @param newValue The new value of the property.
jaroslav@601: * @param index index of the property element that was changed.
jaroslav@601: */
jaroslav@601: public IndexedPropertyChangeEvent(Object source, String propertyName,
jaroslav@601: Object oldValue, Object newValue,
jaroslav@601: int index) {
jaroslav@601: super (source, propertyName, oldValue, newValue);
jaroslav@601: this.index = index;
jaroslav@601: }
jaroslav@601:
jaroslav@601: /**
jaroslav@601: * Gets the index of the property that was changed.
jaroslav@601: *
jaroslav@601: * @return The index specifying the property element that was
jaroslav@601: * changed.
jaroslav@601: */
jaroslav@601: public int getIndex() {
jaroslav@601: return index;
jaroslav@601: }
jaroslav@601:
jaroslav@601: void appendTo(StringBuilder sb) {
jaroslav@601: sb.append("; index=").append(getIndex());
jaroslav@601: }
jaroslav@601: }