datapacket
Class VDataPacket

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.Vector<ADataPacket>
              extended by datapacket.VDataPacket
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<ADataPacket>, java.util.Collection<ADataPacket>, java.util.List<ADataPacket>, java.util.RandomAccess

public class VDataPacket
extends java.util.Vector<ADataPacket>

Composite data type for use in data packets: DataPacket<VDataPacket>
Note that Vector<VDataPacket> cannot be used as a data packet data type directly because type erasure prevents the distinction between Vector<A> and Vector<B> -- that is, they produce the same Class object.
Usage:

      // make the vector of data packets
      VDataPacket vdp = new VDataPacket();
      vdp.add(datapacket1);
      vdp.add(datapacket2);
      vdp.add(datapacket3);
      // etc
      // make the composite data packet
      ADataPacket vd = new DataPacket<VDataPacket>(VDataPacket.class, vdp);
 
This class is a vector of the abstract data packets, ADataPacket. If a vector of more specific types of data packets is desired, a custom class that is a sub-class of the desired Vector type should be used instead of this class. Composites made as such would be distinguishable as per their held types.

Author:
Stephen Wong (c) 2010
See Also:
Serialized Form

Field Summary
private static long serialVersionUID
           
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
VDataPacket()
           
 
Method Summary
static
<R,P> ADataPacketAlgoCmd<java.util.Vector<R>,VDataPacket,P>
makeMapCmd(DataPacketAlgo<R,P> algo)
          Convenience method that creates a command that maps a visitor over the vector of data packets.
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, 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.List
iterator, listIterator, listIterator
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

VDataPacket

public VDataPacket()
Method Detail

makeMapCmd

public static <R,P> ADataPacketAlgoCmd<java.util.Vector<R>,VDataPacket,P> makeMapCmd(DataPacketAlgo<R,P> algo)
Convenience method that creates a command that maps a visitor over the vector of data packets.
Since the result returned by the returned command is a vector of R, the returned command must be wrapped in another command before it can be used in a recursive algorithm, which would require a return of type R.

Type Parameters:
R - The return type of the given visitor.
P - The vararg input parameter type of the original visitor.
Parameters:
algo - The visitor to be mapped over all the stored data packets.
Returns:
An ADataPacketAlgoCmd whose results are a vector of results from applying the given visitor to each data packet element.