jdk/src/share/classes/javax/swing/DefaultListModel.java
author malenkov
Wed, 30 Apr 2014 19:28:05 +0400
changeset 24544 c0133e7c7162
parent 22574 7f8ce0c8c20a
child 25201 4adc75e0c4e5
permissions -rw-r--r--
8041917: unexcepted behavior of LineBorder while using Boolean variable true Reviewed-by: alexsch, serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
22574
7f8ce0c8c20a 8032627: Add @SuppressWarnings("serial") to appropriate javax.swing classes
darcy
parents: 20458
diff changeset
     2
 * Copyright (c) 1997, 2014, 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: 4378
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: 4378
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: 4378
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4378
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4378
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;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.Enumeration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import javax.swing.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * This class loosely implements the <code>java.util.Vector</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * API, in that it implements the 1.1.x version of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * <code>java.util.Vector</code>, has no collection class support,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * and notifies the <code>ListDataListener</code>s when changes occur.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * Presently it delegates to a <code>Vector</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * in a future release it will be a real Collection implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * 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: 5506
diff changeset
    47
 * of all JavaBeans&trade;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *
4378
ef21a120cb18 6823603: Generics: JList
rupashka
parents: 2
diff changeset
    51
 * @param <E> the type of the elements of this model
ef21a120cb18 6823603: Generics: JList
rupashka
parents: 2
diff changeset
    52
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * @author Hans Muller
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 */
22574
7f8ce0c8c20a 8032627: Add @SuppressWarnings("serial") to appropriate javax.swing classes
darcy
parents: 20458
diff changeset
    55
@SuppressWarnings("serial") // Same-version serialization only
4378
ef21a120cb18 6823603: Generics: JList
rupashka
parents: 2
diff changeset
    56
public class DefaultListModel<E> extends AbstractListModel<E>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
{
4378
ef21a120cb18 6823603: Generics: JList
rupashka
parents: 2
diff changeset
    58
    private Vector<E> delegate = new Vector<E>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * Returns the number of components in this list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * This method is identical to <code>size</code>, which implements the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * <code>List</code> interface defined in the 1.2 Collections framework.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * This method exists in conjunction with <code>setSize</code> so that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * <code>size</code> is identifiable as a JavaBean property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * @return  the number of components in this list
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * @see #size()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    public int getSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        return delegate.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * Returns the component at the specified index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * <b>Note:</b> Although this method is not deprecated, the preferred
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     *    method to use is <code>get(int)</code>, which implements the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     *    <code>List</code> interface defined in the 1.2 Collections framework.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * </blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * @param      index   an index into this list
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * @return     the component at the specified index
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * @exception  ArrayIndexOutOfBoundsException  if the <code>index</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     *             is negative or greater than the current size of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     *             list
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * @see #get(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     */
4378
ef21a120cb18 6823603: Generics: JList
rupashka
parents: 2
diff changeset
    89
    public E getElementAt(int index) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        return delegate.elementAt(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * Copies the components of this list into the specified array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * The array must be big enough to hold all the objects in this list,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * else an <code>IndexOutOfBoundsException</code> is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * @param   anArray   the array into which the components get copied
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * @see Vector#copyInto(Object[])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    public void copyInto(Object anArray[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        delegate.copyInto(anArray);
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
     * Trims the capacity of this list to be the list's current size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * @see Vector#trimToSize()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    public void trimToSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        delegate.trimToSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * Increases the capacity of this list, if necessary, to ensure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * that it can hold at least the number of components specified by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * the minimum capacity argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * @param   minCapacity   the desired minimum capacity
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * @see Vector#ensureCapacity(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    public void ensureCapacity(int minCapacity) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        delegate.ensureCapacity(minCapacity);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * Sets the size of this list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * @param   newSize   the new size of this list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @see Vector#setSize(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    public void setSize(int newSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        int oldSize = delegate.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        delegate.setSize(newSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        if (oldSize > newSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            fireIntervalRemoved(this, newSize, oldSize-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        else if (oldSize < newSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            fireIntervalAdded(this, oldSize, newSize-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * Returns the current capacity of this list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * @return  the current capacity
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * @see Vector#capacity()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    public int capacity() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        return delegate.capacity();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * Returns the number of components in this list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * @return  the number of components in this list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * @see Vector#size()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    public int size() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        return delegate.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * Tests whether this list has any components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * @return  <code>true</code> if and only if this list has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     *          no components, that is, its size is zero;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     *          <code>false</code> otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * @see Vector#isEmpty()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    public boolean isEmpty() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        return delegate.isEmpty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * Returns an enumeration of the components of this list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * @return  an enumeration of the components of this list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * @see Vector#elements()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     */
4378
ef21a120cb18 6823603: Generics: JList
rupashka
parents: 2
diff changeset
   181
    public Enumeration<E> elements() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        return delegate.elements();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * Tests whether the specified object is a component in this list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @param   elem   an object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * @return  <code>true</code> if the specified object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     *          is the same as a component in this list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * @see Vector#contains(Object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    public boolean contains(Object elem) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        return delegate.contains(elem);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * Searches for the first occurrence of <code>elem</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * @param   elem   an object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * @return  the index of the first occurrence of the argument in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     *          list; returns <code>-1</code> if the object is not found
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * @see Vector#indexOf(Object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    public int indexOf(Object elem) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        return delegate.indexOf(elem);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * Searches for the first occurrence of <code>elem</code>, beginning
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * the search at <code>index</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * @param   elem    an desired component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * @param   index   the index from which to begin searching
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * @return  the index where the first occurrence of <code>elem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     *          is found after <code>index</code>; returns <code>-1</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     *          if the <code>elem</code> is not found in the list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * @see Vector#indexOf(Object,int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     public int indexOf(Object elem, int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        return delegate.indexOf(elem, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * Returns the index of the last occurrence of <code>elem</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * @param   elem   the desired component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * @return  the index of the last occurrence of <code>elem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     *          in the list; returns <code>-1</code> if the object is not found
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * @see Vector#lastIndexOf(Object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    public int lastIndexOf(Object elem) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        return delegate.lastIndexOf(elem);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * Searches backwards for <code>elem</code>, starting from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * specified index, and returns an index to it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * @param  elem    the desired component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * @param  index   the index to start searching from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * @return the index of the last occurrence of the <code>elem</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     *          in this list at position less than <code>index</code>;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     *          returns <code>-1</code> if the object is not found
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * @see Vector#lastIndexOf(Object,int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    public int lastIndexOf(Object elem, int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        return delegate.lastIndexOf(elem, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * Returns the component at the specified index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * Throws an <code>ArrayIndexOutOfBoundsException</code> if the index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * is negative or not less than the size of the list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * <b>Note:</b> Although this method is not deprecated, the preferred
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     *    method to use is <code>get(int)</code>, which implements the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     *    <code>List</code> interface defined in the 1.2 Collections framework.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * </blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * @param      index   an index into this list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * @return     the component at the specified index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * @see #get(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * @see Vector#elementAt(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     */
4378
ef21a120cb18 6823603: Generics: JList
rupashka
parents: 2
diff changeset
   266
    public E elementAt(int index) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        return delegate.elementAt(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * Returns the first component of this list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * Throws a <code>NoSuchElementException</code> if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * vector has no components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * @return     the first component of this list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * @see Vector#firstElement()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     */
4378
ef21a120cb18 6823603: Generics: JList
rupashka
parents: 2
diff changeset
   277
    public E firstElement() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        return delegate.firstElement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * Returns the last component of the list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * Throws a <code>NoSuchElementException</code> if this vector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * has no components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * @return  the last component of the list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * @see Vector#lastElement()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     */
4378
ef21a120cb18 6823603: Generics: JList
rupashka
parents: 2
diff changeset
   289
    public E lastElement() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        return delegate.lastElement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * Sets the component at the specified <code>index</code> of this
4378
ef21a120cb18 6823603: Generics: JList
rupashka
parents: 2
diff changeset
   295
     * list to be the specified element. The previous component at that
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * position is discarded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * Throws an <code>ArrayIndexOutOfBoundsException</code> if the index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * is invalid.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * <b>Note:</b> Although this method is not deprecated, the preferred
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     *    method to use is <code>set(int,Object)</code>, which implements the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     *    <code>List</code> interface defined in the 1.2 Collections framework.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * </blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     *
4378
ef21a120cb18 6823603: Generics: JList
rupashka
parents: 2
diff changeset
   306
     * @param      element what the component is to be set to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * @param      index   the specified index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * @see #set(int,Object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * @see Vector#setElementAt(Object,int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     */
4378
ef21a120cb18 6823603: Generics: JList
rupashka
parents: 2
diff changeset
   311
    public void setElementAt(E element, int index) {
ef21a120cb18 6823603: Generics: JList
rupashka
parents: 2
diff changeset
   312
        delegate.setElementAt(element, index);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        fireContentsChanged(this, index, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * Deletes the component at the specified index.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * Throws an <code>ArrayIndexOutOfBoundsException</code> if the index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * is invalid.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * <b>Note:</b> Although this method is not deprecated, the preferred
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     *    method to use is <code>remove(int)</code>, which implements the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     *    <code>List</code> interface defined in the 1.2 Collections framework.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * </blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * @param      index   the index of the object to remove
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * @see #remove(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * @see Vector#removeElementAt(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    public void removeElementAt(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        delegate.removeElementAt(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        fireIntervalRemoved(this, index, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    /**
4378
ef21a120cb18 6823603: Generics: JList
rupashka
parents: 2
diff changeset
   337
     * Inserts the specified element as a component in this list at the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * specified <code>index</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * Throws an <code>ArrayIndexOutOfBoundsException</code> if the index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * is invalid.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * <b>Note:</b> Although this method is not deprecated, the preferred
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     *    method to use is <code>add(int,Object)</code>, which implements the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     *    <code>List</code> interface defined in the 1.2 Collections framework.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * </blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     *
4378
ef21a120cb18 6823603: Generics: JList
rupashka
parents: 2
diff changeset
   348
     * @param      element the component to insert
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * @param      index   where to insert the new component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * @exception  ArrayIndexOutOfBoundsException  if the index was invalid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * @see #add(int,Object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * @see Vector#insertElementAt(Object,int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     */
4378
ef21a120cb18 6823603: Generics: JList
rupashka
parents: 2
diff changeset
   354
    public void insertElementAt(E element, int index) {
ef21a120cb18 6823603: Generics: JList
rupashka
parents: 2
diff changeset
   355
        delegate.insertElementAt(element, index);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        fireIntervalAdded(this, index, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * Adds the specified component to the end of this list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     *
4378
ef21a120cb18 6823603: Generics: JList
rupashka
parents: 2
diff changeset
   362
     * @param   element   the component to be added
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * @see Vector#addElement(Object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     */
4378
ef21a120cb18 6823603: Generics: JList
rupashka
parents: 2
diff changeset
   365
    public void addElement(E element) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        int index = delegate.size();
4378
ef21a120cb18 6823603: Generics: JList
rupashka
parents: 2
diff changeset
   367
        delegate.addElement(element);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        fireIntervalAdded(this, index, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     * Removes the first (lowest-indexed) occurrence of the argument
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * from this list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * @param   obj   the component to be removed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * @return  <code>true</code> if the argument was a component of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     *          list; <code>false</code> otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * @see Vector#removeElement(Object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    public boolean removeElement(Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        int index = indexOf(obj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        boolean rv = delegate.removeElement(obj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        if (index >= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
            fireIntervalRemoved(this, index, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        return rv;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * Removes all components from this list and sets its size to zero.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     * <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * <b>Note:</b> Although this method is not deprecated, the preferred
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     *    method to use is <code>clear</code>, which implements the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     *    <code>List</code> interface defined in the 1.2 Collections framework.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * </blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * @see #clear()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * @see Vector#removeAllElements()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    public void removeAllElements() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        int index1 = delegate.size()-1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        delegate.removeAllElements();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        if (index1 >= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
            fireIntervalRemoved(this, 0, index1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * Returns a string that displays and identifies this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * object's properties.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * @return a String representation of this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
   public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        return delegate.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    /* The remaining methods are included for compatibility with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * Java 2 platform Vector class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * Returns an array containing all of the elements in this list in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * correct order.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * @return an array containing the elements of the list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * @see Vector#toArray()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
    public Object[] toArray() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        Object[] rv = new Object[delegate.size()];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        delegate.copyInto(rv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        return rv;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     * Returns the element at the specified position in this list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     * Throws an <code>ArrayIndexOutOfBoundsException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * if the index is out of range
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * (<code>index &lt; 0 || index &gt;= size()</code>).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * @param index index of element to return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     */
4378
ef21a120cb18 6823603: Generics: JList
rupashka
parents: 2
diff changeset
   447
    public E get(int index) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
        return delegate.elementAt(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     * Replaces the element at the specified position in this list with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * specified element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * Throws an <code>ArrayIndexOutOfBoundsException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * if the index is out of range
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     * (<code>index &lt; 0 || index &gt;= size()</code>).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     * @param index index of element to replace
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     * @param element element to be stored at the specified position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * @return the element previously at the specified position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     */
4378
ef21a120cb18 6823603: Generics: JList
rupashka
parents: 2
diff changeset
   463
    public E set(int index, E element) {
ef21a120cb18 6823603: Generics: JList
rupashka
parents: 2
diff changeset
   464
        E rv = delegate.elementAt(index);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        delegate.setElementAt(element, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        fireContentsChanged(this, index, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        return rv;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * Inserts the specified element at the specified position in this list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * Throws an <code>ArrayIndexOutOfBoundsException</code> if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * index is out of range
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     * (<code>index &lt; 0 || index &gt; size()</code>).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * @param index index at which the specified element is to be inserted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     * @param element element to be inserted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     */
4378
ef21a120cb18 6823603: Generics: JList
rupashka
parents: 2
diff changeset
   480
    public void add(int index, E element) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        delegate.insertElementAt(element, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        fireIntervalAdded(this, index, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     * Removes the element at the specified position in this list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * Returns the element that was removed from the list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * Throws an <code>ArrayIndexOutOfBoundsException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     * if the index is out of range
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * (<code>index &lt; 0 || index &gt;= size()</code>).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * @param index the index of the element to removed
4378
ef21a120cb18 6823603: Generics: JList
rupashka
parents: 2
diff changeset
   494
     * @return the element previously at the specified position
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     */
4378
ef21a120cb18 6823603: Generics: JList
rupashka
parents: 2
diff changeset
   496
    public E remove(int index) {
ef21a120cb18 6823603: Generics: JList
rupashka
parents: 2
diff changeset
   497
        E rv = delegate.elementAt(index);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        delegate.removeElementAt(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        fireIntervalRemoved(this, index, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        return rv;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * Removes all of the elements from this list.  The list will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * be empty after this call returns (unless it throws an exception).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    public void clear() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        int index1 = delegate.size()-1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        delegate.removeAllElements();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        if (index1 >= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
            fireIntervalRemoved(this, 0, index1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     * Deletes the components at the specified range of indexes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * The removal is inclusive, so specifying a range of (1,5)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * removes the component at index 1 and the component at index 5,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     * as well as all components in between.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     * Throws an <code>ArrayIndexOutOfBoundsException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     * if the index was invalid.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     * Throws an <code>IllegalArgumentException</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     * <code>fromIndex &gt; toIndex</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     * @param      fromIndex the index of the lower end of the range
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     * @param      toIndex   the index of the upper end of the range
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     * @see        #remove(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
    public void removeRange(int fromIndex, int toIndex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        if (fromIndex > toIndex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
            throw new IllegalArgumentException("fromIndex must be <= toIndex");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
        for(int i = toIndex; i >= fromIndex; i--) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
            delegate.removeElementAt(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        fireIntervalRemoved(this, fromIndex, toIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
    public void addAll(Collection c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    public void addAll(int index, Collection c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
}