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