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

E17503-02

oracle.adfnmc.java.util
Class Vector

java.lang.Object
  extended by oracle.adfnmc.java.util.AbstractCollection
      extended by oracle.adfnmc.java.util.AbstractList
          extended by oracle.adfnmc.java.util.Vector
All Implemented Interfaces:
Serializable, Cloneable, Iterable, Collection, List, RandomAccess
Direct Known Subclasses:
Stack, ViewCriteria

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

Vector is a variable size contiguous indexable array of Objects. The size of the Vector is the number of Objects it contains. The capacity of the Vector is the number of Objects it can hold.

Objects may be inserted at any position up to the size of the Vector, increasing the size of the Vector. Objects at any position in the Vector may be removed, shrinking the size of the Vector. Objects at any position in the Vector may be replaced, which does not affect the Vector size.

The capacity of a Vector may be specified when the Vector is created. If the capacity of the Vector is exceeded, the capacity is increased, doubling by default.

See Also:
StringBuffer

Field Summary
protected  int capacityIncrement
          How many elements should be added to the vector when it is detected that it needs to grow to accommodate extra entries.
protected  int elementCount
          The number of elements or the size of the vector.
protected  java.lang.Object[] elementData
          The elements of the vector.
 
Fields inherited from class oracle.adfnmc.java.util.AbstractList
modCount
 
Constructor Summary
Vector()
          Constructs a new Vector using the default capacity.
Vector(Collection collection)
          Constructs a new instance of Vector containing the elements in collection.
Vector(int capacity)
          Constructs a new Vector using the specified capacity.
Vector(int capacity, int capacityIncrement)
          Constructs a new Vector using the specified capacity and capacity increment.
 
Method Summary
 void add(int location, java.lang.Object object)
          Adds the specified object into this Vector at the specified location.
 boolean add(java.lang.Object object)
          Adds the specified object at the end of this Vector.
 boolean addAll(Collection collection)
          Adds the objects in the specified Collection to the end of this Vector.
 boolean addAll(int location, Collection collection)
          Inserts the objects in the specified Collection at the specified location in this Vector.
 void addElement(java.lang.Object object)
          Adds the specified object at the end of this Vector.
 int capacity()
          Answers the number of elements this Vector can hold without growing.
 void clear()
          Removes all elements from this Vector, leaving it empty.
 java.lang.Object clone()
          Answers a new Vector with the same elements, size, capacity and capacity increment as this Vector.
 boolean contains(java.lang.Object object)
          Searches this Vector for the specified object.
 boolean containsAll(Collection collection)
          Searches this Vector for all objects in the specified Collection.
 void copyInto(java.lang.Object[] elements)
          Attempts to copy elements contained by this Vector into the corresponding elements of the supplied Object array.
 java.lang.Object elementAt(int location)
          Answers the element at the specified location in this Vector.
 java.util.Enumeration elements()
          Answers an Enumeration on the elements of this Vector.
 void ensureCapacity(int minimumCapacity)
          Ensures that this Vector can hold the specified number of elements without growing.
 boolean equals(java.lang.Object object)
          Compares the specified object to this Vector and answer if they are equal.
 java.lang.Object firstElement()
          Answers the first element in this Vector.
 java.lang.Object get(int location)
          Answers the element at the specified location in this Vector.
 int hashCode()
          Answers an integer hash code for the receiver.
 int indexOf(java.lang.Object object)
          Searches in this Vector for the index of the specified object.
 int indexOf(java.lang.Object object, int location)
          Searches in this Vector for the index of the specified object.
 void insertElementAt(java.lang.Object object, int location)
          Inserts the specified object into this Vector at the specified location.
 boolean isEmpty()
          Answers if this Vector has no elements, a size of zero.
 java.lang.Object lastElement()
          Answers the last element in this Vector.
 int lastIndexOf(java.lang.Object object)
          Searches in this Vector for the index of the specified object.
 int lastIndexOf(java.lang.Object object, int location)
          Searches in this Vector for the index of the specified object.
 java.lang.Object remove(int location)
          Removes the object at the specified location from this List.
 boolean remove(java.lang.Object object)
          Removes the first occurrence, starting at the beginning and moving towards the end, of the specified object from this Vector.
 boolean removeAll(Collection collection)
          Removes all occurrences in this Vector of each object in the specified Collection.
 void removeAllElements()
          Removes all elements from this Vector, leaving the size zero and the capacity unchanged.
 boolean removeElement(java.lang.Object object)
          Removes the first occurrence, starting at the beginning and moving towards the end, of the specified object from this Vector.
 void removeElementAt(int location)
          Removes the element found at index position location from this Vector and decrements the size accordingly.
protected  void removeRange(int start, int end)
          Removes the objects in the specified range from the start to the, but not including, end index.
 boolean retainAll(Collection collection)
          Removes all objects from this Vector that are not contained in the specified Collection.
 java.lang.Object set(int location, java.lang.Object object)
          Replaces the element at the specified location in this Vector with the specified object.
 void setElementAt(java.lang.Object object, int location)
          Replaces the element at the specified location in this Vector with the specified object.
 void setSize(int length)
          Sets the size of this Vector to the specified size.
 int size()
          Answers the number of elements in this Vector.
 List subList(int start, int end)
          Answers a List of the specified portion of this Vector from the start index to one less than the end index.
 java.lang.Object[] toArray()
          Answers a new array containing all elements contained in this Vector.
 java.lang.Object[] toArray(java.lang.Object[] contents)
          Answers an array containing all elements contained in this Vector.
 java.lang.String toString()
          Answers the string representation of this Vector.
 void trimToSize()
          Sets the capacity of this Vector to be the same as the size.
 
Methods inherited from class oracle.adfnmc.java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface oracle.adfnmc.java.util.List
iterator, listIterator, listIterator
 

Field Detail

elementCount

protected int elementCount
The number of elements or the size of the vector.


elementData

protected java.lang.Object[] elementData
The elements of the vector.


capacityIncrement

protected int capacityIncrement
How many elements should be added to the vector when it is detected that it needs to grow to accommodate extra entries.

Constructor Detail

Vector

public Vector()
Constructs a new Vector using the default capacity.


Vector

public Vector(int capacity)
Constructs a new Vector using the specified capacity.

Parameters:
capacity - the initial capacity of the new vector

Vector

public Vector(int capacity,
              int capacityIncrement)
Constructs a new Vector using the specified capacity and capacity increment.

Parameters:
capacity - the initial capacity of the new Vector
capacityIncrement - the amount to increase the capacity when this Vector is full

Vector

public Vector(Collection collection)
Constructs a new instance of Vector containing the elements in collection. The order of the elements in the new Vector is dependent on the iteration order of the seed collection.

Parameters:
collection - the collection of elements to add
Method Detail

add

public void add(int location,
                java.lang.Object object)
Adds the specified object into this Vector 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 Vector, 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 the element
object - the object to insert in this Vector
Throws:
java.lang.ArrayIndexOutOfBoundsException - when location < 0 || > size()
See Also:
addElement(java.lang.Object), size()

add

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

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

addAll

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

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

addAll

public boolean addAll(Collection collection)
Adds the objects in the specified Collection to the end of this Vector.

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 Vector is modified, false otherwise

addElement

public void addElement(java.lang.Object object)
Adds the specified object at the end of this Vector.

Parameters:
object - the object to add to the Vector

capacity

public int capacity()
Answers the number of elements this Vector can hold without growing.

Returns:
the capacity of this Vector
See Also:
ensureCapacity(int), size()

clear

public void clear()
Removes all elements from this Vector, 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()
                       throws CloneNotSupportedException
Answers a new Vector with the same elements, size, capacity and capacity increment as this Vector.

Returns:
a shallow copy of this Vector
Throws:
CloneNotSupportedException
See Also:
Cloneable

contains

public boolean contains(java.lang.Object object)
Searches this Vector 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 look for in this Vector
Returns:
true if object is an element of this Vector, false otherwise
See Also:
indexOf(Object), indexOf(Object, int), Object.equals(java.lang.Object)

containsAll

public boolean containsAll(Collection collection)
Searches this Vector for all objects in the specified Collection.

Specified by:
containsAll in interface Collection
Specified by:
containsAll in interface List
Overrides:
containsAll in class AbstractCollection
Parameters:
collection - the Collection of objects
Returns:
true if all objects in the specified Collection are elements of this Vector, false otherwise

copyInto

public void copyInto(java.lang.Object[] elements)
Attempts to copy elements contained by this Vector into the corresponding elements of the supplied Object array.

Parameters:
elements - the Object array into which the elements of this Vector are copied
See Also:
clone()

elementAt

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

Parameters:
location - the index of the element to return in this Vector
Returns:
the element at the specified location
Throws:
java.lang.ArrayIndexOutOfBoundsException - when location < 0 || >= size()
See Also:
size()

elements

public java.util.Enumeration elements()
Answers an Enumeration on the elements of this Vector. The results of the Enumeration may be affected if the contents of this Vector are modified.

Returns:
an Enumeration of the elements of this Vector
See Also:
elementAt(int), Enumeration

ensureCapacity

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

Parameters:
minimumCapacity - the minimum number of elements that this vector will hold before growing
See Also:
capacity()

equals

public boolean equals(java.lang.Object object)
Compares the specified object to this Vector and answer if they are equal. The object must be a List which contains the same objects in the same order.

Specified by:
equals in interface Collection
Specified by:
equals in interface List
Overrides:
equals in class AbstractList
Parameters:
object - the object to compare with this object
Returns:
true if the specified object is equal to this Vector, false otherwise
See Also:
hashCode()

firstElement

public java.lang.Object firstElement()
Answers the first element in this Vector.

Returns:
the element at the first position
Throws:
java.util.NoSuchElementException - when this vector is empty
See Also:
elementAt(int), lastElement(), size()

get

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

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

hashCode

public int hashCode()
Answers an integer hash code for the receiver. Objects which are equal answer the same value for this method.

Specified by:
hashCode in interface Collection
Specified by:
hashCode in interface List
Overrides:
hashCode in class AbstractList
Returns:
the receiver's hash
See Also:
equals(java.lang.Object)

indexOf

public int indexOf(java.lang.Object object)
Searches in this Vector for the index of the specified object. The search for the object starts at the beginning and moves towards the end of this Vector.

Specified by:
indexOf in interface List
Overrides:
indexOf in class AbstractList
Parameters:
object - the object to find in this Vector
Returns:
the index in this Vector of the specified element, -1 if the element isn't found
See Also:
contains(java.lang.Object), lastIndexOf(Object), lastIndexOf(Object, int)

indexOf

public int indexOf(java.lang.Object object,
                   int location)
Searches in this Vector for the index of the specified object. The search for the object starts at the specified location and moves towards the end of this Vector.

Parameters:
object - the object to find in this Vector
location - the index at which to start searching
Returns:
the index in this Vector of the specified element, -1 if the element isn't found
Throws:
java.lang.ArrayIndexOutOfBoundsException - when location < 0
See Also:
contains(java.lang.Object), lastIndexOf(Object), lastIndexOf(Object, int)

insertElementAt

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

Parameters:
object - the object to insert in this Vector
location - the index at which to insert the element
Throws:
java.lang.ArrayIndexOutOfBoundsException - when location < 0 || > size()
See Also:
addElement(java.lang.Object), size()

isEmpty

public boolean isEmpty()
Answers if this Vector 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 Vector has no elements, false otherwise
See Also:
size()

lastElement

public java.lang.Object lastElement()
Answers the last element in this Vector.

Returns:
the element at the last position
Throws:
java.util.NoSuchElementException - when this vector is empty
See Also:
elementAt(int), firstElement(), size()

lastIndexOf

public int lastIndexOf(java.lang.Object object)
Searches in this Vector for the index of the specified object. The search for the object starts at the end and moves towards the start of this Vector.

Specified by:
lastIndexOf in interface List
Overrides:
lastIndexOf in class AbstractList
Parameters:
object - the object to find in this Vector
Returns:
the index in this Vector of the specified element, -1 if the element isn't found
See Also:
contains(java.lang.Object), indexOf(Object), indexOf(Object, int)

lastIndexOf

public int lastIndexOf(java.lang.Object object,
                       int location)
Searches in this Vector for the index of the specified object. The search for the object starts at the specified location and moves towards the start of this Vector.

Parameters:
object - the object to find in this Vector
location - the index at which to start searching
Returns:
the index in this Vector of the specified element, -1 if the element isn't found
Throws:
java.lang.ArrayIndexOutOfBoundsException - when location >= size()
See Also:
contains(java.lang.Object), indexOf(Object), indexOf(Object, int)

remove

public java.lang.Object remove(int location)
Description copied from class: AbstractList
Removes the object at the specified location from this List.

Specified by:
remove in interface List
Overrides:
remove in class AbstractList
Parameters:
location - the index of the object to remove
Returns:
the removed object

remove

public boolean remove(java.lang.Object object)
Removes the first occurrence, starting at the beginning and moving towards the end, of the specified object from this Vector.

Specified by:
remove in interface Collection
Specified by:
remove in interface List
Overrides:
remove in class AbstractCollection
Parameters:
object - the object to remove from this Vector
Returns:
true if the specified object was found, false otherwise
See Also:
removeAllElements(), removeElementAt(int), size()

removeAll

public boolean removeAll(Collection collection)
Removes all occurrences in this Vector of each object in the specified Collection.

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

removeAllElements

public void removeAllElements()
Removes all elements from this Vector, leaving the size zero and the capacity unchanged.

See Also:
isEmpty(), size()

removeElement

public boolean removeElement(java.lang.Object object)
Removes the first occurrence, starting at the beginning and moving towards the end, of the specified object from this Vector.

Parameters:
object - the object to remove from this Vector
Returns:
true if the specified object was found, false otherwise
See Also:
removeAllElements(), removeElementAt(int), size()

removeElementAt

public void removeElementAt(int location)
Removes the element found at index position location from this Vector and decrements the size accordingly.

Parameters:
location - the index of the element to remove
Throws:
java.lang.ArrayIndexOutOfBoundsException - when location < 0 || >= size()
See Also:
removeElement(java.lang.Object), removeAllElements(), size()

removeRange

protected void removeRange(int start,
                           int end)
Removes the objects in the specified range from the start to the, but not including, 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()

retainAll

public boolean retainAll(Collection collection)
Removes all objects from this Vector that are not contained in the specified Collection.

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

set

public java.lang.Object set(int location,
                            java.lang.Object object)
Replaces the element at the specified location in this Vector 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 to this Vector
Returns:
the previous element at the location
Throws:
java.lang.ArrayIndexOutOfBoundsException - when location < 0 || >= size()
See Also:
size()

setElementAt

public void setElementAt(java.lang.Object object,
                         int location)
Replaces the element at the specified location in this Vector with the specified object.

Parameters:
object - the object to add to this Vector
location - the index at which to put the specified object
Throws:
java.lang.ArrayIndexOutOfBoundsException - when location < 0 || >= size()
See Also:
size()

setSize

public void setSize(int length)
Sets the size of this Vector to the specified size. If there are more than length elements in this Vector, the elements at end are lost. If there are less than length elements in the Vector, the additional elements contain null.

Parameters:
length - the new size of this Vector
See Also:
size()

size

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

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 Vector
See Also:
elementCount, lastElement()

subList

public List subList(int start,
                    int end)
Answers a List of the specified portion of this Vector from the start index to one less than the end index. The returned List is backed by this Vector so changes to one are reflected by the other.

Specified by:
subList in interface List
Overrides:
subList in class AbstractList
Parameters:
start - the index at which to start the sublist
end - the index one past the end of the sublist
Returns:
a List of a portion of this Vector
Throws:
java.lang.IndexOutOfBoundsException - when start < 0 or end > size()
java.lang.IllegalArgumentException - when start > end

toArray

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

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 Vector

toArray

public java.lang.Object[] toArray(java.lang.Object[] contents)
Answers an array containing all elements contained in this Vector. 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 Vector, 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 Vector
Throws:
java.lang.ArrayStoreException - when the type of an element in this Vector cannot be stored in the type of the specified array

toString

public java.lang.String toString()
Answers the string representation of this Vector.

Overrides:
toString in class AbstractCollection
Returns:
the string representation of this Vector
See Also:
elements()

trimToSize

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

See Also:
capacity(), ensureCapacity(int), 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.