Oracle Fusion Middleware Java API Reference for Oracle ADF Mobile Client
11g Release 1 (11.1.1)

E17503-02

oracle.adfnmc.java.util
Class ArrayList

java.lang.Object
  extended by oracle.adfnmc.java.util.AbstractCollection
      extended by oracle.adfnmc.java.util.AbstractList
          extended by oracle.adfnmc.java.util.ArrayList
All Implemented Interfaces:
Serializable, Cloneable, Iterable, Collection, List, RandomAccess

public class ArrayList
extends AbstractList
implements List, Cloneable, Serializable, RandomAccess

ArrayList is an implementation of List, backed by an array. All optional operations are supported, adding, removing, and replacing. The elements can be any objects.

Since:
1.2

Field Summary
 
Fields inherited from class oracle.adfnmc.java.util.AbstractList
modCount
 
Constructor Summary
ArrayList()
          Constructs a new instance of ArrayList with capacity for ten elements.
ArrayList(Collection collection)
          Constructs a new instance of ArrayList containing the elements in the specified collection.
ArrayList(int capacity)
          Constructs a new instance of ArrayList with the specified capacity.
ArrayList(Vector vec)
          Constructs a new instance of ArrayList containing the elements in the specified vector.
 
Method Summary
 void add(int location, java.lang.Object object)
          Inserts the specified object into this ArrayList at the specified location.
 boolean add(java.lang.Object object)
          Adds the specified object at the end of this ArrayList.
 boolean addAll(Collection collection)
          Adds the objects in the specified Collection to this ArrayList.
 boolean addAll(int location, Collection collection)
          Inserts the objects in the specified Collection at the specified location in this ArrayList.
 void clear()
          Removes all elements from this ArrayList, leaving it empty.
 java.lang.Object clone()
          Answers a new ArrayList with the same elements, size and capacity as this ArrayList.
 boolean contains(java.lang.Object object)
          Searches this ArrayList for the specified object.
 void ensureCapacity(int minimumCapacity)
          Ensures that this ArrayList can hold the specified number of elements without growing.
 java.lang.Object get(int location)
          Answers the element at the specified location in this ArrayList.
 int indexOf(java.lang.Object object)
          Searches this ArrayList for the specified object and returns the index of the first occurrence.
 boolean isEmpty()
          Answers if this ArrayList has no elements, a size of zero.
 int lastIndexOf(java.lang.Object object)
          Searches this ArrayList for the specified object and returns the index of the last occurrence.
 java.lang.Object remove(int location)
          Removes the object at the specified location from this ArrayList.
 boolean remove(java.lang.Object object)
          Removes the first one of the specified object in this list, if present.
protected  void removeRange(int start, int end)
          Removes the objects in the specified range from the start to the end, but not including the end index.
 java.lang.Object set(int location, java.lang.Object object)
          Replaces the element at the specified location in this ArrayList with the specified object.
 int size()
          Answers the number of elements in this ArrayList.
 java.lang.Object[] toArray()
          Answers a new array containing all elements contained in this ArrayList.
 java.lang.Object[] toArray(java.lang.Object[] contents)
          Answers an array containing all elements contained in this ArrayList.
 void trimToSize()
          Sets the capacity of this ArrayList to be the same as the size.
 
Methods inherited from class oracle.adfnmc.java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class oracle.adfnmc.java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface oracle.adfnmc.java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

ArrayList

public ArrayList()
Constructs a new instance of ArrayList with capacity for ten elements.


ArrayList

public ArrayList(int capacity)
Constructs a new instance of ArrayList with the specified capacity.

Parameters:
capacity - the initial capacity of this ArrayList

ArrayList

public ArrayList(Collection collection)
Constructs a new instance of ArrayList containing the elements in the specified collection. The ArrayList will have an initial capacity which is 110% of the size of the collection. The order of the elements in this ArrayList is the order they are returned by the collection iterator.

Parameters:
collection - the collection of elements to add

ArrayList

public ArrayList(Vector vec)
Constructs a new instance of ArrayList containing the elements in the specified vector. The ArrayList will have an initial capacity which is 110% of the size of the vector. The order of the elements in this ArrayList is the order they are returned by the collection iterator.

Parameters:
vec - the vector of elements to add
Method Detail

add

public void add(int location,
                java.lang.Object object)
Inserts the specified object into this ArrayList at the specified location. The object is inserted before any previous element at the specified location. If the location is equal to the size of this ArrayList, the object is added at the end.

Specified by:
add in interface List
Overrides:
add in class AbstractList
Parameters:
location - the index at which to insert
object - the object to add
Throws:
java.lang.IndexOutOfBoundsException - when location < 0 || >= size()

add

public boolean add(java.lang.Object object)
Adds the specified object at the end of this ArrayList.

Specified by:
add in interface Collection
Specified by:
add in interface List
Overrides:
add in class AbstractList
Parameters:
object - the object to add
Returns:
true

addAll

public boolean addAll(int location,
                      Collection collection)
Inserts the objects in the specified Collection at the specified location in this ArrayList. The objects are added in the order they are returned from the Collection iterator.

Specified by:
addAll in interface List
Overrides:
addAll in class AbstractList
Parameters:
location - the index at which to insert
collection - the Collection of objects
Returns:
true if this ArrayList is modified, false otherwise
Throws:
java.lang.IndexOutOfBoundsException - when location < 0 || > size()

addAll

public boolean addAll(Collection collection)
Adds the objects in the specified Collection to this ArrayList.

Specified by:
addAll in interface Collection
Specified by:
addAll in interface List
Overrides:
addAll in class AbstractCollection
Parameters:
collection - the Collection of objects
Returns:
true if this ArrayList is modified, false otherwise

clear

public void clear()
Removes all elements from this ArrayList, leaving it empty.

Specified by:
clear in interface Collection
Specified by:
clear in interface List
Overrides:
clear in class AbstractList
See Also:
isEmpty(), size()

clone

public java.lang.Object clone()
Answers a new ArrayList with the same elements, size and capacity as this ArrayList.

Returns:
a shallow copy of this ArrayList
See Also:
Cloneable

contains

public boolean contains(java.lang.Object object)
Searches this ArrayList for the specified object.

Specified by:
contains in interface Collection
Specified by:
contains in interface List
Overrides:
contains in class AbstractCollection
Parameters:
object - the object to search for
Returns:
true if object is an element of this ArrayList, false otherwise

ensureCapacity

public void ensureCapacity(int minimumCapacity)
Ensures that this ArrayList can hold the specified number of elements without growing.

Parameters:
minimumCapacity - the minimum number of elements that this ArrayList will hold before growing

get

public java.lang.Object get(int location)
Answers the element at the specified location in this ArrayList.

Specified by:
get in interface List
Specified by:
get in class AbstractList
Parameters:
location - the index of the element to return
Returns:
the element at the specified index
Throws:
java.lang.IndexOutOfBoundsException - when location < 0 || >= size()

indexOf

public int indexOf(java.lang.Object object)
Searches this ArrayList for the specified object and returns the index of the first occurrence.

Specified by:
indexOf in interface List
Overrides:
indexOf in class AbstractList
Parameters:
object - the object to search for
Returns:
the index of the first occurrence of the object

isEmpty

public boolean isEmpty()
Answers if this ArrayList has no elements, a size of zero.

Specified by:
isEmpty in interface Collection
Specified by:
isEmpty in interface List
Overrides:
isEmpty in class AbstractCollection
Returns:
true if this ArrayList has no elements, false otherwise
See Also:
size()

lastIndexOf

public int lastIndexOf(java.lang.Object object)
Searches this ArrayList for the specified object and returns the index of the last occurrence.

Specified by:
lastIndexOf in interface List
Overrides:
lastIndexOf in class AbstractList
Parameters:
object - the object to search for
Returns:
the index of the last occurrence of the object

remove

public java.lang.Object remove(int location)
Removes the object at the specified location from this ArrayList.

Specified by:
remove in interface List
Overrides:
remove in class AbstractList
Parameters:
location - the index of the object to remove
Returns:
the removed object
Throws:
java.lang.IndexOutOfBoundsException - when location < 0 || >= size()

remove

public boolean remove(java.lang.Object object)
Removes the first one of the specified object in this list, if present.

Specified by:
remove in interface Collection
Specified by:
remove in interface List
Overrides:
remove in class AbstractCollection
Parameters:
object - the object to removes
Returns:
true if the list contains the object
See Also:
java.util.AbstractCollection#remove(java.lang.Object)

removeRange

protected void removeRange(int start,
                           int end)
Removes the objects in the specified range from the start to the end, but not including the end index.

Overrides:
removeRange in class AbstractList
Parameters:
start - the index at which to start removing
end - the index one past the end of the range to remove
Throws:
java.lang.IndexOutOfBoundsException - when start < 0, start > end or end > size()

set

public java.lang.Object set(int location,
                            java.lang.Object object)
Replaces the element at the specified location in this ArrayList with the specified object.

Specified by:
set in interface List
Overrides:
set in class AbstractList
Parameters:
location - the index at which to put the specified object
object - the object to add
Returns:
the previous element at the index
Throws:
java.lang.IndexOutOfBoundsException - when location < 0 || >= size()

size

public int size()
Answers the number of elements in this ArrayList.

Specified by:
size in interface Collection
Specified by:
size in interface List
Specified by:
size in class AbstractCollection
Returns:
the number of elements in this ArrayList

toArray

public java.lang.Object[] toArray()
Answers a new array containing all elements contained in this ArrayList.

Specified by:
toArray in interface Collection
Specified by:
toArray in interface List
Overrides:
toArray in class AbstractCollection
Returns:
an array of the elements from this ArrayList

toArray

public java.lang.Object[] toArray(java.lang.Object[] contents)
Answers an array containing all elements contained in this ArrayList. If the specified array is large enough to hold the elements, the specified array is used, otherwise an array of the same type is created. If the specified array is used and is larger than this ArrayList, the array element following the collection elements is set to null.

Specified by:
toArray in interface Collection
Overrides:
toArray in class AbstractCollection
Parameters:
contents - the array
Returns:
an array of the elements from this ArrayList
Throws:
java.lang.ArrayStoreException - when the type of an element in this ArrayList cannot be stored in the type of the specified array

trimToSize

public void trimToSize()
Sets the capacity of this ArrayList to be the same as the size.

See Also:
size()

Oracle Fusion Middleware Java API Reference for Oracle ADF Mobile Client
11g Release 1 (11.1.1)

E17503-02

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.