com.sun.star.lib.uno.helper
public class InterfaceContainer extends Object implements Cloneable
InterfaceContainer cont= new InterfaceContainer(); ListIterator it= cont.listIterator(); cont.add( someInterface); // one cannot obtain someInterface through iterator it, // instead get a new iterator it= cont.listIterator(); // it now keeps a fresh copy of cont and hence contains someInterface // Adding an interface on the iterator will cause the interface also to be added // to InterfaceContainer it.add( someOtherInterface); // someOtherInterface is now in it and cont ListIterator it2= cont.listIterator(); //someOtherInterface can also be obtained by all newly created iterators, e.g. it2.The add and remove methods of an iterator work on a particular location within a list, dependent on what the value of the iterator's cursor is. After the call the value at the appropriate position has been modified. Since the iterator received a copy of InterfaceContainer's data, InterfaceContainer may have been modified (by List methods or through other iterators). Therefore both data sets may not contain the same elements anymore. Consequently, a List method that modifies data, does not modify InterfaceContainer's data at a certain index (according to the iterators cursor). Instead, new elements are added at the end of list. When Iterator.remove is called, then the first occurrence of that element in InterfaceContainer is removed. ListIterator.set is not supported. A lot of methods resemble those of the to java.util.List interface, allthough this class does not implement it. However, the list iterators returned, for example by the listIterator method implement the java.util.ListIterator interface. Implementing the List interface would mean to support all none - optional methods as prescribed by the interface declaration. Among those is the subList method which returns a range of values of the list's data wrapped in a List implementation. Changes to the sub list have to cause changes in the main list. This is a problem, since this class is to be used in a multi-threaded environment. The sub list could work on a copy as the iterators do, but all the functions which work on an given index could not be properly supported. Unfortunatly, the List interface documentation states that all optional methods implemented by the list have to be implemented in the sub list. That would mean to do without all those critical methods, allthough they might work well in the "main list" (as opposed to sub list).
Constructor Summary | |
---|---|
InterfaceContainer() Creates a new instance of InterfaceContainer | |
InterfaceContainer(int initialCapacity)
Constructs an empty list with the specified initial capacity.
|
Method Summary | |
---|---|
boolean | add(Object o)
Appends the specified element to the end of this list.
|
void | add(int index, Object element)
Inserts the specified element at the specified position in this
list. |
boolean | addAll(Collection c)
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 c)
Inserts all of the elements in the specified Collection into this
list, starting at the specified position. |
void | clear()
Removes all of the elements from this list. |
Object | clone()
Returns a shallow copy of this ArrayList instance. |
boolean | contains(Object elem)
Returns true if this list contains the specified element.
|
boolean | containsAll(Collection collection) |
void | disposeAndClear(EventObject evt) |
void | ensureCapacity(int minCapacity)
Increases the capacity of this ArrayList instance, if
necessary, to ensure that it can hold at least the number of elements
specified by the minimum capacity argument.
|
Object | get(int index)
Returns the element at the specified position in this list.
|
int | indexOf(Object elem)
Searches for the first occurence of the given argument, testing
for equality using the equals method.
|
boolean | isEmpty()
Tests if this list has no elements.
|
Iterator | iterator() |
int | lastIndexOf(Object elem)
Returns the index of the last occurrence of the specified object in
this list.
|
ListIterator | listIterator() |
ListIterator | listIterator(int index) The iterator keeps a copy of the list. |
Object | remove(int index)
Removes the element at the specified position in this list.
|
boolean | remove(Object obj) Parameter obj may |
boolean | removeAll(Collection collection) |
boolean | retainAll(Collection collection) |
Object | set(int index, Object element) Not supported. |
int | size()
Returns the number of elements in this list.
|
Object[] | toArray()
Returns an array containing all of the elements in this list
in the correct order.
|
Object[] | toArray(Object[] a)
Returns an array containing all of the elements in this list in the
correct order. |
void | trimToSize()
Trims the capacity of this ArrayList instance to be the
list's current size. |
Parameters: initialCapacity the initial capacity of the list.
Throws: IllegalArgumentException if the specified initial capacity is negative
Parameters: o element to be appended to this list.
Returns: true (as per the general contract of Collection.add).
Parameters: index index at which the specified element is to be inserted. element element to be inserted.
Throws: IndexOutOfBoundsException if index is out of range (index < 0 || index > size()).
Parameters: c the elements to be inserted into this list.
Throws: IndexOutOfBoundsException if index out of range (index < 0 || index > size()).
Parameters: index index at which to insert first element from the specified collection. c elements to be inserted into this list.
Throws: IndexOutOfBoundsException if index out of range (index < 0 || index > size()).
Returns: a clone of this List instance.
Parameters: elem element whose presence in this List is to be tested.
Parameters: minCapacity the desired minimum capacity.
Parameters: index index of element to return.
Returns: the element at the specified position in this list.
Throws: IndexOutOfBoundsException if index is out of range (index < 0 || index >= size()).
Parameters: elem an object.
Returns: the index of the first occurrence of the argument in this list; returns -1 if the object is not found.
See Also: Object#equals(Object)
Returns: true if this list has no elements; false otherwise.
Parameters: elem the desired element.
Returns: the index of the last occurrence of the specified object in this list; returns -1 if the object is not found.
Parameters: index the index of the element to removed.
Returns: the element that was removed from the list.
Throws: IndexOutOfBoundsException if index out of range (index < 0 || index >= size()).
Parameters: index index of element to replace. element element to be stored at the specified position.
Returns: the element previously at the specified position.
Throws: IndexOutOfBoundsException if index out of range (index < 0 || index >= size()).
Returns: the number of elements in this list.
Returns: an array containing all of the elements in this list in the correct order.
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.
Parameters: a 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.
Throws: ArrayStoreException if the runtime type of a is not a supertype of the runtime type of every element in this list.