textbender.g.hold
Class SpoolT

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.Vector<Hold>
              extended by SpoolT
All Implemented Interfaces:
Serializable, Cloneable, Iterable<Hold>, Collection<Hold>, List<Hold>, RandomAccess, Spool

@ThreadSafe
public class SpoolT
extends Vector<Hold>
implements Spool

A thread-safe implementation of a spool, based on a Vector.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Fields inherited from interface Spool
catcher0
 
Constructor Summary
SpoolT()
           
 
Method Summary
 boolean add(Hold hold)
          Adds the hold to the spool, or releases it immediately.
 void add(int index, Hold hold)
           
 boolean addAll(int index, Collection<? extends Hold> c)
           
 void addElement(Hold hold)
           
 void insertElementAt(Hold hold, int index)
           
 boolean isUnwinding()
          Returns true if the spool is unwinding (or unwound).
 List<Hold> subList(int fromIndex, int toIndex)
           
 boolean unwind()
          Commences to unwind this spool.
 boolean unwind(Catcher<Hold> catcher)
          Commences to unwind this spool, removing and releasing each of its holds.
 
Methods inherited from class java.util.Vector
addAll, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Constructor Detail

SpoolT

public SpoolT()
Method Detail

add

public boolean add(Hold hold)
Adds the hold to the spool, or releases it immediately.

Specified by:
add in interface Collection<Hold>
Specified by:
add in interface List<Hold>
Specified by:
add in interface Spool
Overrides:
add in class Vector<Hold>
Returns:
true if the hold is added; false if it is released instead
Throws:
IllegalArgumentException - if the hold is not annotated thread-safe

addAll

public boolean addAll(int index,
                      Collection<? extends Hold> c)
Specified by:
addAll in interface List<Hold>
Overrides:
addAll in class Vector<Hold>

add

public void add(int index,
                Hold hold)
Specified by:
add in interface List<Hold>
Overrides:
add in class Vector<Hold>

subList

public List<Hold> subList(int fromIndex,
                          int toIndex)
Specified by:
subList in interface List<Hold>
Overrides:
subList in class Vector<Hold>

isUnwinding

public boolean isUnwinding()
Description copied from interface: Spool
Returns true if the spool is unwinding (or unwound). Once true, it never reverts to false.

Specified by:
isUnwinding in interface Spool

unwind

public boolean unwind()
Description copied from interface: Spool
Commences to unwind this spool. Equivalent to unwind(catcher0).

Specified by:
unwind in interface Spool
Returns:
true if unwinding commences with this call; false if it had already commenced

unwind

public boolean unwind(Catcher<Hold> catcher)
Description copied from interface: Spool
Commences to unwind this spool, removing and releasing each of its holds. Works in LIFO order. Once unwinding is commenced, subsequent calls to this method have no effect.

Specified by:
unwind in interface Spool
Parameters:
catcher - for any errors or exceptions that occur during unwinding
Returns:
true if unwinding commences with this call; false if it had already commenced

addElement

public void addElement(Hold hold)
Overrides:
addElement in class Vector<Hold>

insertElementAt

public void insertElementAt(Hold hold,
                            int index)
Overrides:
insertElementAt in class Vector<Hold>