org.jcreme.processing
Class DefaultConsumer

java.lang.Object
  extended byorg.jcreme.processing.DefaultConsumer
All Implemented Interfaces:
Consumer
Direct Known Subclasses:
ParseConsumer, ProducerMultiplexer

public class DefaultConsumer
extends java.lang.Object
implements Consumer

Default implementation of the Consumer interface. This basically the only implementation needed that refers directly to the provider. Other implementation of the Consumer Interface will probably simply aggregate an instance of this class.

Version:
$Revision: 1.3 $
Author:
$Author: dbregeon $
See Also:
Consumer, Producer

Constructor Summary
DefaultConsumer(Producer provider)
          Creates new DefaultConsumer
 
Method Summary
 java.lang.Object consumeItem()
          Consumes a new item.
 Producer getProvider()
          eturns the producer associated with the consumer.
 void setProvider(Producer provider)
          Sets the producer whose objects the consumer will consume.
 boolean validateItem(java.lang.Object item)
          Tells the parent producer that this consumer has finished with this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultConsumer

public DefaultConsumer(Producer provider)
                throws java.lang.IllegalArgumentException
Creates new DefaultConsumer

Parameters:
provider - The provider of the DefaultConsumer.
Throws:
java.lang.IllegalArgumentException - if provider is null.
Method Detail

getProvider

public Producer getProvider()
eturns the producer associated with the consumer.

Specified by:
getProvider in interface Consumer
Returns:
The producer from wich the consumer member will get the objects to consume.
See Also:
Consumer.getProvider()

consumeItem

public java.lang.Object consumeItem()
Consumes a new item.

Specified by:
consumeItem in interface Consumer
Returns:
The object produced by the consumption of a new item.
See Also:
Consumer.consumeItem()

validateItem

public boolean validateItem(java.lang.Object item)
Tells the parent producer that this consumer has finished with this object.

Specified by:
validateItem in interface Consumer
Parameters:
item - an item that was previously retrieved through the consumeItem method.
Returns:
true is item was successfully validated.

setProvider

public void setProvider(Producer provider)
                 throws java.lang.IllegalArgumentException
Sets the producer whose objects the consumer will consume.

Specified by:
setProvider in interface Consumer
Parameters:
provider - The producer to be set.
Throws:
java.lang.IllegalArgumentException - In case the type of the given producer doesn't match the expected type.


Copyright 2006 null. All Rights Reserved.