com.tenduke.distribution
Class DistributionRequests

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<AbstractDistributionRequest>
              extended by com.tenduke.distribution.DistributionRequests
All Implemented Interfaces:
DistributionRequestResultSubscriber, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<AbstractDistributionRequest>, java.util.Collection<AbstractDistributionRequest>, java.util.List<AbstractDistributionRequest>, java.util.RandomAccess

public class DistributionRequests
extends java.util.ArrayList<AbstractDistributionRequest>
implements DistributionRequestResultSubscriber

Class wrapping a list of AbstractDistributionRequest objects that should be handled as an entity.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
DistributionRequests()
           
 
Method Summary
 boolean add(AbstractDistributionRequest element)
          Subscribes to distribution request events and appends the specified request object to the end of this list.
 void add(int index, AbstractDistributionRequest element)
          Subscribes to distribution request events and inserts the specified request object at the specified position in this list.
 boolean addAll(java.util.Collection<? extends AbstractDistributionRequest> collection)
          Appends all of the requests 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, java.util.Collection<? extends AbstractDistributionRequest> collection)
          Inserts all of the requests in the specified collection into this list, starting at the specified position.
protected  void finalize()
          Un-subscribes from all distribution request events.
 void handleDistributionRequestResult(DistributionRequestResult result)
          Handle result of a single DistributionRequest wrapped by this object.
 void notifySubscribers(DistributionRequestsResult results)
          Notify all DistributionRequests results subscribers.
 AbstractDistributionRequest remove(int index)
          Un-subscribes distribution request events and removes the request object at the specified position in this list.
 boolean remove(java.lang.Object request)
          Un-subscribes distribution request events and removes the first occurrence of the specified request object from this list, if it is present.
 boolean removeAll(java.util.Collection<?> collection)
          Un-subscribes distribution request events and removes all of this collection's request objects that are also contained in the specified collection.
protected  void removeRange(int fromIndex, int toIndex)
          Un-subscribes distribution request events and removes from this list all of the request objects whose index is between fromIndex, inclusive, and toIndex, exclusive.
 boolean retainAll(java.util.Collection<?> collection)
          Un-subscribes distribution request events and retains only the request objects in this collection that are contained in the specified collection (optional operation).
 void subscribeResults(DistributionRequestResultsSubscriber subscriber)
          Add an object as DistributionRequest result subscriber.
 void unsubscribeResults(DistributionRequestResultsSubscriber subscriber)
          Remove a DistributionRequest result subscriber.
 
Methods inherited from class java.util.ArrayList
clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, subList
 

Constructor Detail

DistributionRequests

public DistributionRequests()
Method Detail

add

public boolean add(AbstractDistributionRequest element)
Subscribes to distribution request events and appends the specified request object to the end of this list.

Specified by:
add in interface java.util.Collection<AbstractDistributionRequest>
Specified by:
add in interface java.util.List<AbstractDistributionRequest>
Overrides:
add in class java.util.ArrayList<AbstractDistributionRequest>
Parameters:
element - Request to add.
Returns:
true (as specified by Collection.add(E))

add

public void add(int index,
                AbstractDistributionRequest element)
Subscribes to distribution request events and inserts the specified request object at the specified position in this list. Shifts the request object currently at that position (if any) and any subsequent request objects to the right (adds one to their indices).

Specified by:
add in interface java.util.List<AbstractDistributionRequest>
Overrides:
add in class java.util.ArrayList<AbstractDistributionRequest>
Parameters:
index - The index at which the new request object should be added to.
element - Request to add.

addAll

public boolean addAll(java.util.Collection<? extends AbstractDistributionRequest> collection)
Appends all of the requests 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.)

Specified by:
addAll in interface java.util.Collection<AbstractDistributionRequest>
Specified by:
addAll in interface java.util.List<AbstractDistributionRequest>
Overrides:
addAll in class java.util.ArrayList<AbstractDistributionRequest>
Parameters:
collection - Collection containing requests to be added to this list.
Returns:
true if this list changed as a result of the call

addAll

public boolean addAll(int index,
                      java.util.Collection<? extends AbstractDistributionRequest> collection)
Inserts all of the requests in the specified collection into this list, starting at the specified position. Shifts the request object currently at that position (if any) and any subsequent request objects to the right (increases their indices). The new request objects will appear in the list in the order that they are returned by the specified collection's iterator.

Specified by:
addAll in interface java.util.List<AbstractDistributionRequest>
Overrides:
addAll in class java.util.ArrayList<AbstractDistributionRequest>
Parameters:
index - Index at which to insert the first request object from the specified collection.
collection - Collection containing requests to be added to this list.
Returns:
true if this list changed as a result of the call.

finalize

protected void finalize()
                 throws java.lang.Throwable
Un-subscribes from all distribution request events.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

handleDistributionRequestResult

public void handleDistributionRequestResult(DistributionRequestResult result)
Handle result of a single DistributionRequest wrapped by this object.

Specified by:
handleDistributionRequestResult in interface DistributionRequestResultSubscriber
Parameters:
result - The result object to handle.

notifySubscribers

public void notifySubscribers(DistributionRequestsResult results)
Notify all DistributionRequests results subscribers.

Parameters:
results - DistributionRequestsResult object to pass to the subscribers.

remove

public AbstractDistributionRequest remove(int index)
Un-subscribes distribution request events and removes the request object at the specified position in this list. Shifts any subsequent request objects to the left (subtracts one from their indices).

Specified by:
remove in interface java.util.List<AbstractDistributionRequest>
Overrides:
remove in class java.util.ArrayList<AbstractDistributionRequest>
Parameters:
index - the index of the request object to be removed.
Returns:
The request that was removed from the list.

remove

public boolean remove(java.lang.Object request)
Un-subscribes distribution request events and removes the first occurrence of the specified request object from this list, if it is present. If the list does not contain the request object, it is unchanged. More formally, removes the request object with the lowest index i such that (o == null ? get(i) == null : o.equals(get(i))) (if such an request object exists). Returns true if this list contained the specified request object (or equivalently, if this list changed as a result of the call).

Specified by:
remove in interface java.util.Collection<AbstractDistributionRequest>
Specified by:
remove in interface java.util.List<AbstractDistributionRequest>
Overrides:
remove in class java.util.ArrayList<AbstractDistributionRequest>
Parameters:
request - The request to remove.
Returns:
true if this list contained the specified request.

removeAll

public boolean removeAll(java.util.Collection<?> collection)
Un-subscribes distribution request events and removes all of this collection's request objects that are also contained in the specified collection. After this call returns, this collection will contain no request objects in common with the specified collection. This implementation iterates over this collection, checking each request object returned by the iterator in turn to see if it's contained in the specified collection. If it's so contained, it's removed from this collection with the iterator's remove method. Note that this implementation will throw an UnsupportedOperationException if the iterator returned by the iterator method does not implement the remove method and this collection contains one or more request objects in common with the specified collection.

Specified by:
removeAll in interface java.util.Collection<AbstractDistributionRequest>
Specified by:
removeAll in interface java.util.List<AbstractDistributionRequest>
Overrides:
removeAll in class java.util.AbstractCollection<AbstractDistributionRequest>
Parameters:
collection -
Returns:
true if this collection changed as a result of the call.

removeRange

protected void removeRange(int fromIndex,
                           int toIndex)
Un-subscribes distribution request events and removes from this list all of the request objects whose index is between fromIndex, inclusive, and toIndex, exclusive. Shifts any succeeding request objects to the left (reduces their index). This call shortens the list by (toIndex - fromIndex) request objects. (If toIndex==fromIndex, this operation has no effect.)

Overrides:
removeRange in class java.util.ArrayList<AbstractDistributionRequest>
Parameters:
fromIndex - index of first request object to be removed.
toIndex - index after last request object to be removed.
Throws:
java.lang.IndexOutOfBoundsException - if fromIndex or toIndex out of range (fromIndex < 0 || fromIndex >= size() || toIndex > size() || toIndex < fromIndex).

retainAll

public boolean retainAll(java.util.Collection<?> collection)
Un-subscribes distribution request events and retains only the request objects in this collection that are contained in the specified collection (optional operation). In other words, removes from this collection all of its request objects that are not contained in the specified collection. This implementation iterates over this collection, checking each request object returned by the iterator in turn to see if it's contained in the specified collection. If it's not so contained, it's removed from this collection with the iterator's remove method. Note that this implementation will throw an UnsupportedOperationException if the iterator returned by the iterator method does not implement the remove method and this collection contains one or more request objects not present in the specified collection.

Specified by:
retainAll in interface java.util.Collection<AbstractDistributionRequest>
Specified by:
retainAll in interface java.util.List<AbstractDistributionRequest>
Overrides:
retainAll in class java.util.AbstractCollection<AbstractDistributionRequest>
Parameters:
collection - containing request objects to be retained in this collection.
Returns:
true if this collection changed as a result of the call.

subscribeResults

public void subscribeResults(DistributionRequestResultsSubscriber subscriber)
Add an object as DistributionRequest result subscriber. Result subscribers handleDistributionRequestResult method will be called when DistributionRequest results are available.

Parameters:
subscriber - Subscriber to add.

unsubscribeResults

public void unsubscribeResults(DistributionRequestResultsSubscriber subscriber)
Remove a DistributionRequest result subscriber.

Parameters:
subscriber - Subscriber to remove.