jdk/src/share/classes/javax/swing/event/ListDataEvent.java
author rriggs
Tue, 03 Jun 2014 11:18:03 -0400
changeset 25122 1ecc464c69d2
parent 23010 6dadb192ad81
permissions -rw-r--r--
8044460: Cleanup new Boolean and single character strings Reviewed-by: pchelko, serb, rriggs Contributed-by: otaviopolianasantana@gmail.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 20458
diff changeset
     2
 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.swing.event;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.EventObject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * Defines an event that encapsulates changes to a list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * the same version of Swing.  As of 1.4, support for long term storage
20458
f2423fb3fd19 8025840: Fix all the doclint warnings about trademark
cl
parents: 20428
diff changeset
    39
 * of all JavaBeans&trade;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * @author Hans Muller
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 */
11268
f0e59c4852de 7116950: Reduce number of warnings in swing
alexsch
parents: 5506
diff changeset
    45
@SuppressWarnings("serial")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
public class ListDataEvent extends EventObject
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    /** Identifies one or more changes in the lists contents. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    public static final int CONTENTS_CHANGED = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    /** Identifies the addition of one or more contiguous items to the list */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    public static final int INTERVAL_ADDED = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    /** Identifies the removal of one or more contiguous items from the list */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    public static final int INTERVAL_REMOVED = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    private int type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private int index0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    private int index1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * Returns the event type. The possible values are:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * <li> {@link #CONTENTS_CHANGED}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * <li> {@link #INTERVAL_ADDED}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * <li> {@link #INTERVAL_REMOVED}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * @return an int representing the type value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    public int getType() { return type; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * Returns the lower index of the range. For a single
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * element, this value is the same as that returned by {@link #getIndex1}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * @return an int representing the lower index value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    public int getIndex0() { return index0; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * Returns the upper index of the range. For a single
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * element, this value is the same as that returned by {@link #getIndex0}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * @return an int representing the upper index value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    public int getIndex1() { return index1; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    /**
20428
929cd48fca8a 8025249: [javadoc] fix some javadoc errors in javax/swing/
yan
parents: 11268
diff changeset
    88
     * Constructs a ListDataEvent object. If index0 is &gt;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * index1, index0 and index1 will be swapped such that
20428
929cd48fca8a 8025249: [javadoc] fix some javadoc errors in javax/swing/
yan
parents: 11268
diff changeset
    90
     * index0 will always be &lt;= index1.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @param source  the source Object (typically <code>this</code>)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @param type    an int specifying {@link #CONTENTS_CHANGED},
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     *                {@link #INTERVAL_ADDED}, or {@link #INTERVAL_REMOVED}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * @param index0  one end of the new interval
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * @param index1  the other end of the new interval
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    public ListDataEvent(Object source, int type, int index0, int index1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        super(source);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        this.type = type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        this.index0 = Math.min(index0, index1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        this.index1 = Math.max(index0, index1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * Returns a string representation of this ListDataEvent. This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * is intended to be used only for debugging purposes, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * content and format of the returned string may vary between
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * implementations. The returned string may be empty but may not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * be <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * @return  a string representation of this ListDataEvent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        return getClass().getName() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        "[type=" + type +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        ",index0=" + index0 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        ",index1=" + index1 + "]";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
}