org.jcreme.processing
Class MonitorableProducer

java.lang.Object
  extended byorg.jcreme.processing.MonitorableProducer
All Implemented Interfaces:
MonitorableTask, Producer

public class MonitorableProducer
extends java.lang.Object
implements MonitorableTask, Producer

This class describes a producer with a self-monitoring capability handled through the MonitorableTask interface

Version:
$Revision: 1.3 $
Author:
$Author: dbregeon $
See Also:
MonitorableTask

Field Summary
protected  BaseTaskActivityMonitor taskActivityMonitor
          The ActivityMonitor associated with the producer.
 
Constructor Summary
MonitorableProducer(AbstractProducer producer)
          Creates new MonitorableProducer
 
Method Summary
 AbstractProducer getProducer()
          Gets the monitored producer
 TaskActivityMonitor getTaskActivityMonitor()
          Returns the Monitorable Producer's ActivityMonitor.
 boolean isProductionOver()
          Returns true if the production is over, false if not.
 java.lang.Object nextItem()
          Returns the next item free for consumption.
 boolean produceItem()
          Produces an item, i.e. marks it as consumable.
 void setProductionOver(boolean b)
          Sets a flag that shows whether the production is over.
protected  void updateCompletionPercentage()
          Updates the producer's ActivityMonitor's completiuon percentage value.
 boolean validateItem(java.lang.Object theItem)
          Validates an item, i.e. marks it as having been consumed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

taskActivityMonitor

protected BaseTaskActivityMonitor taskActivityMonitor
The ActivityMonitor associated with the producer.

See Also:
TaskActivityMonitor
Constructor Detail

MonitorableProducer

public MonitorableProducer(AbstractProducer producer)
Creates new MonitorableProducer

Parameters:
producer - The producer whose activity will be monitored.
Method Detail

produceItem

public boolean produceItem()
Produces an item, i.e. marks it as consumable.

Specified by:
produceItem in interface Producer
Returns:
True if there are still objects to produce. False otherwise.
See Also:
Producer.produceItem()

setProductionOver

public void setProductionOver(boolean b)
Sets a flag that shows whether the production is over.

Specified by:
setProductionOver in interface Producer
Parameters:
b - The boolean value which the flag has to be set on.
See Also:
Producer.setProductionOver(boolean)

validateItem

public boolean validateItem(java.lang.Object theItem)
Validates an item, i.e. marks it as having been consumed. Also updates the ActivityMonitor's completion percentage value.

Specified by:
validateItem in interface Producer
Parameters:
theItem - The item to be validated.
Returns:
true if theItem was successfully validated.
See Also:
Producer.validateItem(java.lang.Object)

getTaskActivityMonitor

public TaskActivityMonitor getTaskActivityMonitor()
Returns the Monitorable Producer's ActivityMonitor.

Specified by:
getTaskActivityMonitor in interface MonitorableTask
Returns:
the monitor that dispatches the information about this task.
See Also:
MonitorableTask.getTaskActivityMonitor()

updateCompletionPercentage

protected final void updateCompletionPercentage()
Updates the producer's ActivityMonitor's completiuon percentage value.


nextItem

public java.lang.Object nextItem()
Returns the next item free for consumption.

Specified by:
nextItem in interface Producer
Returns:
The next item free for consumption.

isProductionOver

public final boolean isProductionOver()
Returns true if the production is over, false if not.

Specified by:
isProductionOver in interface Producer
Returns:
True if the production is over, false if not.

getProducer

public AbstractProducer getProducer()
Gets the monitored producer

Returns:
The producer being monitored.


Copyright 2006 null. All Rights Reserved.