com.plumtree.openfoundation.util
Class XPArrayList

java.lang.Object
  extended bycom.plumtree.openfoundation.util.XPArrayList
All Implemented Interfaces:
IXPCollection, IXPList

public class XPArrayList
extends java.lang.Object
implements IXPList

XPArrayList is a wrapper over the ArrayList.


Constructor Summary
XPArrayList()
          Creates an empty list.
XPArrayList(java.util.Collection list)
          Constructs a list from a pre-existing ArrayList
XPArrayList(int initialCapacity)
          Constructs an empty list with the specified initial capacity.
 
Method Summary
 int Add(java.lang.Object value)
          Appends the specified element to the end of this list.
 void AddRange(IXPCollection collection)
          Appends all of the elements in the specified Collection to the end of this list.
 void Clear()
          Removes all elements from this list.
 java.lang.Object Clone()
          Returns a shallow copy of this XPArrayList instance.
 boolean Contains(java.lang.Object value)
          Determines whether an element is in this list.
 boolean ContainsAll(IXPCollection collection)
          Determines if this list contains all of the elements in the specified collection.
 java.lang.Object GetElement(int index)
          Returns the element at the specified position in this list.
 IXPEnumerator GetEnumerator()
          Returns an XPEnumerator that can iterate through this list.
 int GetSize()
          Returns the number of elements in this list.
 java.util.ArrayList GetUnderlyingObject()
          Returns the platfrom specific object that this class wraps.
 int IndexOf(java.lang.Object value)
          Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.
 void Insert(int index, java.lang.Object value)
          Inserts an element into this list at the specified index, shifting the current element at that index and the rest of the list to the right by 1.
 void InsertRange(int index, IXPCollection collection)
          Inserts the elements of a collection into this list at the specified index.
 boolean IsEmpty()
          Tests if this list has no elements.
 int LastIndexOf(java.lang.Object _value)
          Returns the index of the last occurrence of the specified object in this list.
 void Remove(java.lang.Object value)
          Removes a single instance of the specified element from this list, if it is present.
 void RemoveAll(IXPCollection collection)
          Removes from this list all of its elements that are contained in the specified collection.
 java.lang.Object RemoveAt(int index)
          Removes the element at the specified position in this list.
 void RetainAll(IXPCollection collection)
          Retains only the elements in this list that are contained in the specified collection.
 java.lang.Object SetElement(int index, java.lang.Object value)
          Replaces the element at the specified position in this list with the specified element.
 java.lang.Object[] ToArray()
          Returns an array containing all of the elements in this list in the correct order.
 java.lang.Object[] ToArray(java.lang.Object[] arr)
          Returns an array containing all of the elements in this list in the correct order; the runtime type of the returned array is that of the specified array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XPArrayList

public XPArrayList()
Creates an empty list.


XPArrayList

public XPArrayList(int initialCapacity)
Constructs an empty list with the specified initial capacity.

Parameters:
initialCapacity - the initial capacity of the list.

XPArrayList

public XPArrayList(java.util.Collection list)
Constructs a list from a pre-existing ArrayList

Parameters:
list - an ArrayList whose contents are added to the internal ArrayList of this XPArrayList
Method Detail

Add

public int Add(java.lang.Object value)
Appends the specified element to the end of this list.

Specified by:
Add in interface IXPCollection
Parameters:
value - The element to be appended to this list.
Returns:
The index at which the value has been added (always the last index, size-1).

AddRange

public void AddRange(IXPCollection collection)
Appends all of the elements in the specified Collection to the end of this list.

Specified by:
AddRange in interface IXPCollection
Parameters:
collection - The collection whose elements should be appended to this list.

Clear

public void Clear()
Removes all elements from this list.

Specified by:
Clear in interface IXPCollection

Clone

public java.lang.Object Clone()
Returns a shallow copy of this XPArrayList instance. The elements themselves are not cloned, but their references are duplicated in the new list.

Returns:
a clone of this XPArrayList instance.

Contains

public boolean Contains(java.lang.Object value)
Determines whether an element is in this list.

Specified by:
Contains in interface IXPCollection
Parameters:
value - The element whose presence in this list is to be tested.
Returns:
true if item is found in the ArrayList; otherwise, false.

ContainsAll

public boolean ContainsAll(IXPCollection collection)
Determines if this list contains all of the elements in the specified collection.

Specified by:
ContainsAll in interface IXPCollection
Parameters:
collection - The collection to be checked for containment in this list.
Returns:
true if this list contains all of the elements in the specified collection; otherwise false.

GetElement

public java.lang.Object GetElement(int index)
Returns the element at the specified position in this list.

Specified by:
GetElement in interface IXPList
Parameters:
index - index of element to return.
Returns:
the element at the specified position in this list.

GetEnumerator

public IXPEnumerator GetEnumerator()
Returns an XPEnumerator that can iterate through this list.

Specified by:
GetEnumerator in interface IXPCollection
Returns:
An XPEnumerator that can iterate through this list.

GetSize

public int GetSize()
Returns the number of elements in this list.

Specified by:
GetSize in interface IXPCollection
Returns:
The number of elements in this list.

GetUnderlyingObject

public java.util.ArrayList GetUnderlyingObject()
Returns the platfrom specific object that this class wraps.

Returns:
An instance of ArrayList.

IndexOf

public int IndexOf(java.lang.Object value)
Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.

Parameters:
value - element to search for.
Returns:
the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.

Insert

public void Insert(int index,
                   java.lang.Object value)
Inserts an element into this list at the specified index, shifting the current element at that index and the rest of the list to the right by 1. It is legal to append an element by inserting at an index one greater than the last element.

Specified by:
Insert in interface IXPCollection
Parameters:
index - The zero-based index at which value should be inserted.
value - The object to insert.

InsertRange

public void InsertRange(int index,
                        IXPCollection collection)
Inserts the elements of a collection into this list at the specified index.

Specified by:
InsertRange in interface IXPCollection
Parameters:
index - The zero-based index at which the new elements of the collection should be inserted.
collection - The collection whose elements should be inserted.

IsEmpty

public boolean IsEmpty()
Tests if this list has no elements.

Specified by:
IsEmpty in interface IXPCollection
Returns:
true if this list has no elements; false otherwise.

LastIndexOf

public int LastIndexOf(java.lang.Object _value)
Returns the index of the last occurrence of the specified object in this list.

Parameters:
_value - The element to search for.
Returns:
the index of the last occurrence of the specified object in this list; returns -1 if the object is not found.

Remove

public void Remove(java.lang.Object value)
Removes a single instance of the specified element from this list, if it is present. Shifts any subsequent elements to the left (subtracts one from their indices). No exception will be thrown if the input element is not found.

Specified by:
Remove in interface IXPCollection
Parameters:
value - The element that was removed from the list.

RemoveAll

public void RemoveAll(IXPCollection collection)
Removes from this list all of its elements that are contained in the specified collection.

Specified by:
RemoveAll in interface IXPCollection
Parameters:
collection - The collection that contains the elements to be removed from this list.

RemoveAt

public java.lang.Object RemoveAt(int index)
Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices).

Specified by:
RemoveAt in interface IXPCollection
Parameters:
index - the index of the element to removed.
Returns:
The element that was removed from the list.

RetainAll

public void RetainAll(IXPCollection collection)
Retains only the elements in this list that are contained in the specified collection. In other words, removes from this list all of its elements that are not contained in the specified collection.

Specified by:
RetainAll in interface IXPCollection
Parameters:
collection - The collection that contains the elements to be retained in this list.

SetElement

public java.lang.Object SetElement(int index,
                                   java.lang.Object value)
Replaces the element at the specified position in this list with the specified element.

Specified by:
SetElement in interface IXPList
Parameters:
index - index of element to replace.
value - element to be stored at the specified position.
Returns:
The element previously at the specified position.

ToArray

public java.lang.Object[] ToArray()
Returns an array containing all of the elements in this list in the correct order.

Specified by:
ToArray in interface IXPCollection
Returns:
an array containing all of the elements in this list in the correct order.

ToArray

public java.lang.Object[] ToArray(java.lang.Object[] arr)
Returns an array containing all of the elements in this list in the correct order; the runtime type of the returned array is that of the specified array. If the list fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this list. If the list fits in the specified array with room to spare (i.e., the array has more elements than the list), the element in the array immediately following the end of the collection is set to null. This is useful in determining the length of the list only if the caller knows that the list does not contain any null elements.

Specified by:
ToArray in interface IXPCollection
Parameters:
arr - the array into which the elements of the list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
Returns:
an array containing the elements of the list.


Copyright 2002, 2003, 2004 Plumtree Software Inc. All Rights Reserved.