Top Description Inners Fields Constructors Methods
com.sun.star.lib.uno.helper

public Class InterfaceContainer

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Imports
java.util.Iterator, .ListIterator, .Collection, com.sun.star.lang.EventObject, com.sun.star.lang.XEventListener, com.sun.star.uno.UnoRuntime

This class is a container for interfaces. It is intended to be used as storage for UNO interface of a specific type. The client has to ensure that the container contains only elements of the same type. If one needs to store different types, then one uses OMultiTypeInterfaceContainer. When the client calls disposeAndClear, the contained objects are queried for com.sun.star.lang.XEventListener and disposing is called. Afterwards the list cannot be used anymore. This list does not allow null values. All methods are thread-safe. The same holds true for iterators, issued by this class. Several iterators can exist at the same time and can also be modified (java.util.ListIterator.add, java.util.ListIterator.remove etc.). To make this work, the InterfaceContainer provides the iterators with copies of the list's data. The add and remove calls on the iterator modify the data in the iterator's list as well as in InterfaceContainer. Modification on InterfaceContainer, however, are not synchronized with existing iterators. For example
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, although 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 a given index could not be properly supported. Unfortunately, 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, although they might work well in the "main list" (as opposed to sub list).

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private class

Field Summary

Modifier and TypeField and Description
pack-priv static final boolean
pack-priv Object[]
elementData

The array buffer into which the elements of the ArrayList are stored.

private int
size

The size of the ArrayList (the number of elements it contains).

Constructor Summary

AccessConstructor and Description
public
InterfaceContainer()

Creates a new instance of InterfaceContainer

public
InterfaceContainer(int
the initial capacity of the list.
initialCapacity
)

Constructs an empty list with the specified initial capacity.

private

Method Summary

Modifier and TypeMethod and Description
public synchronized boolean

Returns:

true (as per the general contract of Collection.add).
add
(Object
element to be appended to this list.
o
)

Appends the specified element to the end of this list.

public synchronized void
add(int
index at which the specified element is to be inserted.
index
,
Object
element to be inserted.
element
)

Inserts the specified element at the specified position in this list.

public synchronized boolean

Returns:

true if an element was inserted.
addAll
(Collection<E>
the elements to be inserted into this list.
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.

public synchronized boolean

Returns:

true if an element was inserted.
addAll
(int
index at which to insert first element from the specified collection.
index
,
Collection<E>
elements to be inserted into this list.
c
)

Inserts all of the elements in the specified Collection into this list, starting at the specified position.

public synchronized void
clear()

Removes all of the elements from this list.

public synchronized Object

Returns:

a clone of this List instance.
clone
()

Overrides java.lang.Object.clone.

Returns a shallow copy of this ArrayList instance.

public synchronized boolean

Returns:

true if this list contains the specified element.
contains
(Object
element whose presence in this List is to be tested.
elem
)

Returns true if this list contains the specified element.

public synchronized boolean
containsAll(Collection<E> collection)

public void
disposeAndClear(com.sun.star.lang.EventObject evt)

public synchronized void
ensureCapacity(int
the desired minimum capacity.
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.

public synchronized Object

Returns:

the element at the specified position in this list.
get
(int
index of element to return.
index
)

Returns the element at the specified position in this list.

public synchronized int

Returns:

the index of the first occurrence of the argument in this list; returns -1 if the object is not found.
indexOf
(Object
an object.
elem
)

Searches for the first occurrence of the given argument, testing for equality using the equals method.

public synchronized boolean

Returns:

true if this list has no elements; false otherwise.
isEmpty
()

Tests if this list has no elements.

public synchronized Iterator<E>
public synchronized int

Returns:

the index of the last occurrence of the specified object in this list; returns -1 if the object is not found.
lastIndexOf
(Object
the desired element.
elem
)

Returns the index of the last occurrence of the specified object in this list.

public synchronized ListIterator<E>
public synchronized ListIterator<E>

Returns:

a new iterator.
listIterator
(int
the starting offset into the list.
index
)

The iterator keeps a copy of the list.

private void
RangeCheck(int index)

Check if the given index is in range.

public synchronized Object

Returns:

the element that was removed from the list.
remove
(int
the index of the element to removed.
index
)

Removes the element at the specified position in this list.

public synchronized boolean

Returns:

true if obj was successfully removed from the list.
remove
(Object
the object to be removed.
obj
)

Parameter obj may...

public synchronized boolean
removeAll(Collection<E> collection)

public synchronized boolean
retainAll(Collection<E> collection)

public synchronized Object

Returns:

the element previously at the specified position.
set
(int
index of element to replace.
index
,
Object
element to be stored at the specified position.
element
)

Not supported.

public synchronized int

Returns:

the number of elements in this list.
size
()

Returns the number of elements in this list.

public synchronized Object[]

Returns:

an array containing all of the elements in this list in the correct order.
toArray
()

Returns an array containing all of the elements in this list in the correct order.

public synchronized Object[]

Returns:

an array containing the elements of the list.
toArray
(Object[]
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.
a
)

Returns an array containing all of the elements in this list in the correct order.

public synchronized void
trimToSize()

Trims the capacity of this ArrayList instance to be the list's current size.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEBUGback to summary
pack-priv static final boolean DEBUG
elementDataback to summary
pack-priv Object[] elementData

The array buffer into which the elements of the ArrayList are stored. The capacity of the ArrayList is the length of this array buffer.

sizeback to summary
private int size

The size of the ArrayList (the number of elements it contains).

Constructor Detail

InterfaceContainerback to summary
public InterfaceContainer()

Creates a new instance of InterfaceContainer

InterfaceContainerback to summary
public InterfaceContainer(int initialCapacity)

Constructs an empty list with the specified initial capacity.

Parameters
initialCapacity:int

the initial capacity of the list.

Exceptions
IllegalArgumentException:
if the specified initial capacity is negative
InterfaceContainerback to summary
private InterfaceContainer(Object[] data)

Method Detail

addback to summary
public synchronized boolean add(Object o)

Appends the specified element to the end of this list.

Parameters
o:Object

element to be appended to this list.

Returns:boolean

true (as per the general contract of Collection.add).

addback to summary
public synchronized 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).

Parameters
index:int

index at which the specified element is to be inserted.

element:Object

element to be inserted.

Exceptions
IndexOutOfBoundsException:
if index is out of range (index < 0 || index > size()).
addAllback to summary
public synchronized boolean addAll(Collection<E> 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. 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.)

Parameters
c:Collection<E>

the elements to be inserted into this list.

Returns:boolean

true if an element was inserted.

Exceptions
IndexOutOfBoundsException:
if index out of range (index < 0 || index > size()).
addAllback to summary
public synchronized boolean addAll(int index, Collection<E> c)

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.

Parameters
index:int

index at which to insert first element from the specified collection.

c:Collection<E>

elements to be inserted into this list.

Returns:boolean

true if an element was inserted.

Exceptions
IndexOutOfBoundsException:
if index out of range (index < 0 || index > size()).
clearback to summary
public synchronized void clear()

Removes all of the elements from this list. The list will be empty after this call returns.

cloneback to summary
public synchronized Object clone()

Overrides java.lang.Object.clone.

Returns a shallow copy of this ArrayList instance. The contained references are copied but the objects not.

Returns:Object

a clone of this List instance.

Annotations
@Override
containsback to summary
public synchronized boolean contains(Object elem)

Returns true if this list contains the specified element.

Parameters
elem:Object

element whose presence in this List is to be tested.

Returns:boolean

true if this list contains the specified element.

containsAllback to summary
public synchronized boolean containsAll(Collection<E> collection)
disposeAndClearback to summary
public void disposeAndClear(com.sun.star.lang.EventObject evt)
ensureCapacityback to summary
public synchronized 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.

Parameters
minCapacity:int

the desired minimum capacity.

getback to summary
public synchronized Object get(int index)

Returns the element at the specified position in this list.

Parameters
index:int

index of element to return.

Returns:Object

the element at the specified position in this list.

Exceptions
IndexOutOfBoundsException:
if index is out of range (index < 0 || index >= size()).
indexOfback to summary
public synchronized int indexOf(Object elem)

Searches for the first occurrence of the given argument, testing for equality using the equals method.

Parameters
elem:Object

an object.

Returns:int

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)
isEmptyback to summary
public synchronized boolean isEmpty()

Tests if this list has no elements.

Returns:boolean

true if this list has no elements; false otherwise.

iteratorback to summary
public synchronized Iterator<E> iterator()
lastIndexOfback to summary
public synchronized int lastIndexOf(Object elem)

Returns the index of the last occurrence of the specified object in this list.

Parameters
elem:Object

the desired element.

Returns:int

the index of the last occurrence of the specified object in this list; returns -1 if the object is not found.

listIteratorback to summary
public synchronized ListIterator<E> listIterator()
listIteratorback to summary
public synchronized ListIterator<E> listIterator(int index)

The iterator keeps a copy of the list. Changes to InterfaceContainer do not affect the data of the iterator. Conversely, changes to the iterator are effect InterfaceContainer.

Parameters
index:int

the starting offset into the list.

Returns:ListIterator<E>

a new iterator.

RangeCheckback to summary
private void RangeCheck(int index)

Check if the given index is in range. If not, throw an appropriate runtime exception.

removeback to summary
public synchronized Object remove(int index)

Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices).

Parameters
index:int

the index of the element to removed.

Returns:Object

the element that was removed from the list.

Exceptions
IndexOutOfBoundsException:
if index out of range (index < 0 || index >= size()).
removeback to summary
public synchronized boolean remove(Object obj)

Parameter obj may... or may not. What did the original author want to tell us here?

Parameters
obj:Object

the object to be removed.

Returns:boolean

true if obj was successfully removed from the list.

removeAllback to summary
public synchronized boolean removeAll(Collection<E> collection)
retainAllback to summary
public synchronized boolean retainAll(Collection<E> collection)
setback to summary
public synchronized Object set(int index, Object element)

Not supported.

Parameters
index:int

index of element to replace.

element:Object

element to be stored at the specified position.

Returns:Object

the element previously at the specified position.

Exceptions
IndexOutOfBoundsException:
if index out of range (index < 0 || index >= size()).
sizeback to summary
public synchronized int size()

Returns the number of elements in this list.

Returns:int

the number of elements in this list.

toArrayback to summary
public synchronized Object[] toArray()

Returns an array containing all of the elements in this list in the correct order.

Returns:Object[]

an array containing all of the elements in this list in the correct order.

toArrayback to summary
public synchronized Object[] toArray(Object[] a)

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.

Parameters
a:Object[]

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:Object[]

an array containing the elements of the list.

Exceptions
ArrayStoreException:
if the runtime type of a is not a supertype of the runtime type of every element in this list.
trimToSizeback to summary
public synchronized void trimToSize()

Trims the capacity of this ArrayList instance to be the list's current size. An application can use this operation to minimize the storage of an ArrayList instance.

com.sun.star.lib.uno.helper back to summary

private Class InterfaceContainer.Itr

extends Object
implements Iterator
Class Inheritance
All Implemented Interfaces
java.util.Iterator
Known Direct Subclasses
com.sun.star.lib.uno.helper.InterfaceContainer.LstItr

Field Summary

Modifier and TypeField and Description
pack-priv int
cursor

Index of element to be returned by subsequent call to next.

pack-priv InterfaceContainer
pack-priv int
lastRet

Index of element returned by most recent call to next or previous.

pack-priv Object
lastRetObj

The object that has been returned by most recent call to next or previous.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public synchronized boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.

public synchronized Object
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.

public synchronized void
remove()

Overrides default java.util.Iterator.remove.

Removes the interface from the list, that has been last returned by a call to next().

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cursorback to summary
pack-priv int cursor

Index of element to be returned by subsequent call to next.

dataItback to summary
pack-priv InterfaceContainer dataIt
lastRetback to summary
pack-priv int lastRet

Index of element returned by most recent call to next or previous. Reset to -1 if this element is deleted by a call to remove.

lastRetObjback to summary
pack-priv Object lastRetObj

The object that has been returned by most recent call to next or previous. Reset to null if this element is deleted by a call to remove.

Constructor Detail

Itrback to summary
pack-priv Itr(InterfaceContainer _data)

Method Detail

hasNextback to summary
public synchronized boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

nextback to summary
public synchronized Object next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

removeback to summary
public synchronized void remove()

Overrides default java.util.Iterator.remove.

Removes the interface from the list, that has been last returned by a call to next(). This is done according to the specification of the interface method. The element is also removed from InterfaceContainer but independent of the location. If the element is multiple times in InterfaceContainer then it is up to the java.util.ArrayList implementation what element is removed.

com.sun.star.lib.uno.helper back to summary

private Class InterfaceContainer.LstItr

extends Itr
implements ListIterator
Class Inheritance
All Implemented Interfaces
java.util.ListIterator, java.util.Iterator

Field Summary

Inherited from com.sun.star.lib.uno.helper.InterfaceContainer.Itr:
cursordataItlastRetlastRetObj

Constructor Summary

AccessConstructor and Description
pack-priv
LstItr(InterfaceContainer _data, int _index)

Method Summary

Modifier and TypeMethod and Description
public synchronized void
add(Object o)

Implements java.util.ListIterator.add.

Inserts an element to the iterators list according to the specification of this interface method.

public synchronized boolean
hasPrevious()

Implements java.util.ListIterator.hasPrevious.

Returns true if this list iterator has more elements when traversing the list in the reverse direction.

public synchronized int
nextIndex()

Implements java.util.ListIterator.nextIndex.

Returns the index of the element that would be returned by a subsequent call to next.

public synchronized Object
previous()

Implements java.util.ListIterator.previous.

Returns the previous element in the list and moves the cursor position backwards.

public synchronized int
previousIndex()

Implements java.util.ListIterator.previousIndex.

Returns the index of the element that would be returned by a subsequent call to previous.

public synchronized void
set(Object o)

Implements java.util.ListIterator.set.

This is not possible since several iterators can modify InterfaceContainer

Inherited from com.sun.star.lib.uno.helper.InterfaceContainer.Itr:
hasNextnextremove

Constructor Detail

LstItrback to summary
pack-priv LstItr(InterfaceContainer _data, int _index)

Method Detail

addback to summary
public synchronized void add(Object o)

Implements java.util.ListIterator.add.

Inserts an element to the iterators list according to the specification of this interface method. The element is also added to InterfaceContainer but its location within the list cannot be guaranteed.

hasPreviousback to summary
public synchronized boolean hasPrevious()

Implements java.util.ListIterator.hasPrevious.

Doc from java.util.ListIterator.hasPrevious.

Returns true if this list iterator has more elements when traversing the list in the reverse direction. (In other words, returns true if previous would return an element rather than throwing an exception.)

nextIndexback to summary
public synchronized int nextIndex()

Implements java.util.ListIterator.nextIndex.

Doc from java.util.ListIterator.nextIndex.

Returns the index of the element that would be returned by a subsequent call to next. (Returns list size if the list iterator is at the end of the list.)

previousback to summary
public synchronized Object previous()

Implements java.util.ListIterator.previous.

Doc from java.util.ListIterator.previous.

Returns the previous element in the list and moves the cursor position backwards. This method may be called repeatedly to iterate through the list backwards, or intermixed with calls to next to go back and forth. (Note that alternating calls to next and previous will return the same element repeatedly.)

previousIndexback to summary
public synchronized int previousIndex()

Implements java.util.ListIterator.previousIndex.

Doc from java.util.ListIterator.previousIndex.

Returns the index of the element that would be returned by a subsequent call to previous. (Returns -1 if the list iterator is at the beginning of the list.)

setback to summary
public synchronized void set(Object o)

Implements java.util.ListIterator.set.

This is not possible since several iterators can modify InterfaceContainer