org.jcreme.processing
Class BaseProducer

java.lang.Object
  extended byorg.jcreme.processing.AbstractProducer
      extended byorg.jcreme.processing.BaseProducer
All Implemented Interfaces:
Producer
Direct Known Subclasses:
ParseProducer

public abstract class BaseProducer
extends AbstractProducer

This is a base implementation of the Producer interface. It provides all the needed interactions with a Consumer source. Most actual producers should basically simply extend this class.

Version:
$Revision: 1.2 $
Author:
$Author: dbregeon $
See Also:
Producer

Constructor Summary
BaseProducer(int initialProductionQueueSize, int initialValidationQueueSize, Consumer source)
          Creates new BaseProducer
 
Method Summary
protected abstract  java.lang.Object actualProduce(java.lang.Object sourceItem)
          This method does that actual production work.
protected  java.util.Hashtable getProducedToConsumed()
          Provides access to the producedToConsumed association.
protected  Consumer getSource()
          Provides access to the source consumer.
 boolean produceItem()
          Produces an item, i.e. marks it as consumable.
 boolean validateItem(java.lang.Object theItem)
          Validates an item, i.e. marks it as having been consumed.
 
Methods inherited from class org.jcreme.processing.AbstractProducer
getItemsBeingConsumed, getProducedItems, isProductionOver, nextItem, nextItem, publishItem, setProductionOver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseProducer

public BaseProducer(int initialProductionQueueSize,
                    int initialValidationQueueSize,
                    Consumer source)
Creates new BaseProducer

Parameters:
initialProductionQueueSize - the size of the production queue when it is initialized.
initialValidationQueueSize - the size of the validation queue when it is initialized.
source - the consumer from which the producer will get its source objects.
Method Detail

getSource

protected Consumer getSource()
Provides access to the source consumer.

Returns:
the source.

produceItem

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

Specified by:
produceItem in interface Producer
Specified by:
produceItem in class AbstractProducer
Returns:
true if the method actually produced an item, false otherwise.
See Also:
Producer.produceItem()

actualProduce

protected abstract java.lang.Object actualProduce(java.lang.Object sourceItem)
This method does that actual production work.

Parameters:
sourceItem - the item that will enable to produce a result.
Returns:
the object produced.

validateItem

public boolean validateItem(java.lang.Object theItem)
Validates an item, i.e. marks it as having been consumed. The method then validates the object that enabled to produce the item in the source consumer.

Specified by:
validateItem in interface Producer
Overrides:
validateItem in class AbstractProducer
Parameters:
theItem - The item to be validated.
Returns:
true if the validation was successful.
See Also:
Producer.validateItem(java.lang.Object)

getProducedToConsumed

protected java.util.Hashtable getProducedToConsumed()
Provides access to the producedToConsumed association.

Returns:
the producedToConsumed hashtable.


Copyright 2006 null. All Rights Reserved.