com.opensymphony.xwork2.conversion.impl

## Class XWorkList

- java.lang.Object
- - java.util.AbstractCollection<E>
  - - java.util.AbstractList<E>
    - - java.util.ArrayList
      - - com.opensymphony.xwork2.conversion.impl.XWorkList

- All Implemented Interfaces:
    Serializable, Cloneable, Iterable, Collection, List, RandomAccess

      public class XWorkList
      extends ArrayList

  A simple list that guarantees that inserting and retrieving objects will always work regardless of the current size of the list. Upon insertion, type conversion is also performed if necessary. Empty beans will be created to fill the gap between the current list size and the requested index using ObjectFactory's `buildBean` method.
  Author:
    Patrick Lightbody
  See Also:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from class java.util.AbstractList

      `modCount`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `XWorkList(Class clazz)`
    `XWorkList(Class clazz, int initialCapacity)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(int index, Object element)` Inserts the specified element at the specified position in this list.
    `boolean` | `add(Object element)` Appends the specified element to the end of this list.
    `boolean` | `addAll(Collection collection)` Appends all of the elements in the specified Collection to the end of this list, in the order that they are returned by the specified Collection's Iterator.
    `boolean` | `addAll(int index, Collection collection)` Inserts all of the elements in the specified Collection into this list, starting at the specified position.
    `boolean` | `contains(Object element)`
    `Object` | `get(int index)` Returns the element at the specified position in this list.
    `Object` | `set(int index, Object element)` Replaces the element at the specified position in this list with the specified element.

    - ### Methods inherited from class java.util.ArrayList

      `clear, clone, ensureCapacity, forEach, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, size, sort, spliterator, subList, toArray, toArray, trimToSize`

    - ### Methods inherited from class java.util.AbstractList

      `equals, hashCode`

    - ### Methods inherited from class java.util.AbstractCollection

      `containsAll, toString`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.util.List

      `containsAll, equals, hashCode`

    - ### Methods inherited from interface java.util.Collection

      `parallelStream, stream`

- - ### Constructor Detail

    - #### XWorkList

          public XWorkList(Class clazz)

    - #### XWorkList

          public XWorkList(Class clazz,
                           int initialCapacity)

  - ### Method Detail

    - #### add

          public void add(int index,
                          Object element)

      Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

      This method is guaranteed to work since it will create empty beans to fill the gap between the current list size and the requested index to enable the element to be set. This method also performs any necessary type conversion.

      Specified by:
        `add` in interface `List`
      Overrides:
        `add` in class `ArrayList`
      Parameters:
        `index` - index at which the specified element is to be inserted.
        `element` - element to be inserted.

    - #### add

          public boolean add(Object element)

      Appends the specified element to the end of this list.

      This method performs any necessary type conversion.

      Specified by:
        `add` in interface `Collection`
      Specified by:
        `add` in interface `List`
      Overrides:
        `add` in class `ArrayList`
      Parameters:
        `element` - element to be appended to this list.
      Returns:
        `true` (as per the general contract of Collection.add).

    - #### addAll

          public boolean addAll(Collection collection)

      Appends all of the elements in the specified Collection to the end of this list, in the order that they are returned by the specified Collection's Iterator. The behavior of this operation is undefined if the specified Collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified Collection is this list, and this list is nonempty.)

      This method performs any necessary type conversion.

      Specified by:
        `addAll` in interface `Collection`
      Specified by:
        `addAll` in interface `List`
      Overrides:
        `addAll` in class `ArrayList`
      Parameters:
        `collection` - the elements to be inserted into this list.
      Returns:
        `true` if this list changed as a result of the call.
      Throws:
        `NullPointerException` - if the specified collection is null.

    - #### addAll

          public boolean addAll(int index,
                                Collection collection)

      Inserts all of the elements in the specified Collection into this list, starting at the specified position. Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in the list in the order that they are returned by the specified Collection's iterator.

      This method is guaranteed to work since it will create empty beans to fill the gap between the current list size and the requested index to enable the element to be set. This method also performs any necessary type conversion.

      Specified by:
        `addAll` in interface `List`
      Overrides:
        `addAll` in class `ArrayList`
      Parameters:
        `index` - index at which to insert first element from the specified collection.
        `collection` - elements to be inserted into this list.
      Returns:
        `true` if this list changed as a result of the call.

    - #### get

          public Object get(int index)

      Returns the element at the specified position in this list.

      An object is guaranteed to be returned since it will create empty beans to fill the gap between the current list size and the requested index.

      Specified by:
        `get` in interface `List`
      Overrides:
        `get` in class `ArrayList`
      Parameters:
        `index` - index of element to return.
      Returns:
        the element at the specified position in this list.

    - #### set

          public Object set(int index,
                            Object element)

      Replaces the element at the specified position in this list with the specified element.

      This method is guaranteed to work since it will create empty beans to fill the gap between the current list size and the requested index to enable the element to be set. This method also performs any necessary type conversion.

      Specified by:
        `set` in interface `List`
      Overrides:
        `set` in class `ArrayList`
      Parameters:
        `index` - index of element to replace.
        `element` - element to be stored at the specified position.
      Returns:
        the element previously at the specified position.

    - #### contains

          public boolean contains(Object element)

      Specified by:
        `contains` in interface `Collection`
      Specified by:
        `contains` in interface `List`
      Overrides:
        `contains` in class `ArrayList`

Copyright © 2000–2026 Apache Software Foundation. All rights reserved.