Evaluating Software Design Patterns
— the "Gang of Four" patterns implemented in Java 6

dk.rode.thesis.iterator
Class LoggingValueProcessor

java.lang.Object
  extended by dk.rode.thesis.iterator.LoggingValueProcessor
All Implemented Interfaces:
ValueProcessor<Object>

public class LoggingValueProcessor
extends Object
implements ValueProcessor<Object>

A logging value processor logs the first X number of sequence values during processing, where X is supplied at construction time.

A logging processor can handle any type of sequence values.

Implementation notes:
This processor mimics the functionality of the internal iterator described by Gamma et al. [Gamma95, p.268].

Author:
Gunni Rode / rode.dk

Field Summary
private  int count
          The current number of processed sequence values.
private  int maximum
          The maximum number of sequence values to log.
 
Constructor Summary
LoggingValueProcessor()
          Constructor.
LoggingValueProcessor(int maximum)
          Constructor.
 
Method Summary
 void initialise()
          Resets the internal counter to zero.
 boolean process(Object value)
          Process a given value and returns false if the processing is done, true if it must continue.
 String toString()
          Returns the string representation of this processor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

count

private int count
The current number of processed sequence values.

Range: 0 <= count <= min({@link #maximum}, size-of-sequence)

This count will be set to zero on initialisation.


maximum

private final int maximum
The maximum number of sequence values to log.

A value of Const.INFINITE means that the processing will not be stopped by this processor.

Constructor Detail

LoggingValueProcessor

public LoggingValueProcessor()
Constructor.

All sequence values will be logged.


LoggingValueProcessor

public LoggingValueProcessor(int maximum)
Constructor.

Parameters:
maximum - The maximum number of sequence values to log; must be larger than zero or Const.INFINITE.
Throws:
NullPointerException - If maximum is illegal.
Method Detail

initialise

public void initialise()
Resets the internal counter to zero.

Specified by:
initialise in interface ValueProcessor<Object>

process

public boolean process(Object value)
Description copied from interface: ValueProcessor
Process a given value and returns false if the processing is done, true if it must continue.

Specified by:
process in interface ValueProcessor<Object>
Parameters:
value - The value to process; never null.
Returns:
False to stop processing, true to continue.
See Also:
ProcessableSequence.process(ValueProcessor)

toString

public String toString()
Returns the string representation of this processor.

Overrides:
toString in class Object
Returns:
The string representation; never null.

Gunni Rode / rode.dk

Feel free to use and/or modify the Java 6 source code developed for this thesis AT YOUR OWN RISK, but note that the source code comes WITHOUT ANY — and I do mean WITHOUT ANY — form of warranty WHAT SO EVER!

The original thesis and source code are available at rode.dk/thesis.