org.knowceans.sandbox
Class ListPrinter<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.Vector<E>
              extended by org.knowceans.sandbox.ListPrinter<E>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.List<E>, java.util.RandomAccess

public class ListPrinter<E>
extends java.util.Vector<E>

Convienience class to print lists. Should also work with other collections. Users can set the public fields entry* and list* to control printing behaviour. Further, a simple line breaking mechanism is implemented.

Author:
heinrich
See Also:
Serialized Form

Field Summary
 java.lang.String entryEnd
           
 java.lang.String entrySeparator
           
 java.lang.String entryStart
           
 java.lang.String listEnd
           
 java.lang.String listStart
           
 
Constructor Summary
ListPrinter()
          empty printer (backed by a Vector).
ListPrinter(java.util.Collection<E> c)
          printer for Collection.
ListPrinter(int linewidth)
          empty printer (backed by a Vector) with an approximate line width.
ListPrinter(int linewidth, java.util.Collection<E> c)
          printer for Collection with an approximate line width.
ListPrinter(ListPrinter<? extends E> lp)
          create an empty ListPrinter object from the configuration of an existing one.
ListPrinter(ListPrinter lp, java.util.Collection<E> c)
          create ListPrinter object for the Collection from the configuration of an existing ListPrinter.
 
Method Summary
 void set(java.util.Collection<E> c)
          resets the printer content, but keeps the configuration.
 java.lang.String toString()
          worker method to print out the list.
 
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, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Field Detail

entryStart

public java.lang.String entryStart

entryEnd

public java.lang.String entryEnd

entrySeparator

public java.lang.String entrySeparator

listStart

public java.lang.String listStart

listEnd

public java.lang.String listEnd
Constructor Detail

ListPrinter

public ListPrinter()
empty printer (backed by a Vector).


ListPrinter

public ListPrinter(java.util.Collection<E> c)
printer for Collection.

Parameters:
c -

ListPrinter

public ListPrinter(int linewidth)
empty printer (backed by a Vector) with an approximate line width.

Parameters:
linewidth -

ListPrinter

public ListPrinter(ListPrinter<? extends E> lp)
create an empty ListPrinter object from the configuration of an existing one.

Parameters:
lp -

ListPrinter

public ListPrinter(ListPrinter lp,
                   java.util.Collection<E> c)
create ListPrinter object for the Collection from the configuration of an existing ListPrinter.

Parameters:
lp -

ListPrinter

public ListPrinter(int linewidth,
                   java.util.Collection<E> c)
printer for Collection with an approximate line width.

Parameters:
linewidth -
c -
Method Detail

set

public void set(java.util.Collection<E> c)
resets the printer content, but keeps the configuration.

Parameters:
c -

toString

public java.lang.String toString()
worker method to print out the list.

Overrides:
toString in class java.util.Vector<E>