Textractor API textractor-720 (20091120123250)

textractor.chain
Class AbstractSentenceProducer

java.lang.Object
  extended by textractor.sentence.AbstractSentenceProcessor
      extended by textractor.chain.AbstractSentenceProducer
All Implemented Interfaces:
Callable<Boolean>, EventListener, Chain, Command, SentenceProcessingCompleteListener, SentenceProcessor, SentenceProducer, TextractorProcessor
Direct Known Subclasses:
AbstractFileLoader, StringArrayProducer

public abstract class AbstractSentenceProducer
extends AbstractSentenceProcessor
implements Chain, SentenceProducer, SentenceProcessingCompleteListener, Callable<Boolean>

Base class for Chain implementations that contain one or more SentenceProcessor commands.


Field Summary
protected  List<Command> commands
          The list of Commands configured for this Chain, in the order in which they may delegate processing to the remainder of the Chain.
protected  boolean frozen
          Flag indicating whether the configuration of our commands list has been frozen by a call to the execute() method.
 
Fields inherited from interface org.apache.commons.chain.Command
CONTINUE_PROCESSING, PROCESSING_COMPLETE
 
Constructor Summary
AbstractSentenceProducer()
          Create a new Chain.
AbstractSentenceProducer(Collection<Command> commands)
          Construct a Chain configured with the specified Commands.
AbstractSentenceProducer(Command command)
          Construct a Chain configured with the specified Command.
AbstractSentenceProducer(Command[] commands)
          Construct a Chain configured with the specified Commands.
 
Method Summary
 void addCommand(Command command)
          See the Chain JavaDoc.
 boolean execute(Context context)
          See the Chain JavaDoc.
 int getWorkQueueSize()
          Get the size of the sentence production queue.
 void processingComplete(SentenceProcessingCompleteEvent event)
          This method gets called when a sentence processing is complete.
protected  void produce(Article article, Collection<Sentence> sentences)
          Create a article sentence pair object from the individual objects for a sentence consumer to process.
 void setWorkQueueSize(int size)
          Set the size of the sentence production queue.
 
Methods inherited from class textractor.sentence.AbstractSentenceProcessor
addSentenceProcessedListener, addSentenceProcessingCompleteListener, fireSentenceProcessedEvent, fireSentenceProcessingCompleteEvent, removeSentenceProcessedListener, removeSentenceProcessingCompleteListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface textractor.sentence.SentenceProducer
produce
 
Methods inherited from interface textractor.sentence.SentenceProcessor
addSentenceProcessedListener, addSentenceProcessingCompleteListener, getNumberOfArticlesProcessed, getNumberOfSentencesProcessed, removeSentenceProcessedListener, removeSentenceProcessingCompleteListener
 
Methods inherited from interface java.util.concurrent.Callable
call
 

Field Detail

commands

protected final List<Command> commands
The list of Commands configured for this Chain, in the order in which they may delegate processing to the remainder of the Chain.


frozen

protected boolean frozen
Flag indicating whether the configuration of our commands list has been frozen by a call to the execute() method.

Constructor Detail

AbstractSentenceProducer

public AbstractSentenceProducer()
Create a new Chain.


AbstractSentenceProducer

public AbstractSentenceProducer(Command command)
Construct a Chain configured with the specified Command.

Parameters:
command - The Command to be configured
Throws:
IllegalArgumentException - if command is null

AbstractSentenceProducer

public AbstractSentenceProducer(Command[] commands)
Construct a Chain configured with the specified Commands.

Parameters:
commands - The Commands to be configured
Throws:
IllegalArgumentException - if commands, or one of the individual Command elements, is null

AbstractSentenceProducer

public AbstractSentenceProducer(Collection<Command> commands)
Construct a Chain configured with the specified Commands.

Parameters:
commands - The Commands to be configured
Throws:
IllegalArgumentException - if commands, or one of the individual Command elements, is null
Method Detail

addCommand

public final void addCommand(Command command)
See the Chain JavaDoc.

Specified by:
addCommand in interface Chain
Parameters:
command - The Command to be added
Throws:
IllegalArgumentException - if command is null
IllegalStateException - if no further configuration is allowed

execute

public final boolean execute(Context context)
                      throws Exception
See the Chain JavaDoc.

Specified by:
execute in interface Chain
Specified by:
execute in interface Command
Parameters:
context - The Context to be processed by this Chain
Returns:
true if the processing of this Context has been completed, or false if the processing of this Context should be delegated to a subsequent Command in an enclosing Chain
Throws:
Exception - if there is a problem executing the Chain.
IllegalArgumentException - if context is null

produce

protected final void produce(Article article,
                             Collection<Sentence> sentences)
Create a article sentence pair object from the individual objects for a sentence consumer to process.

Parameters:
article - The article assoicated with the sentences.
sentences - A collection of Sentences to process.

processingComplete

public void processingComplete(SentenceProcessingCompleteEvent event)
Description copied from interface: SentenceProcessingCompleteListener
This method gets called when a sentence processing is complete.

Specified by:
processingComplete in interface SentenceProcessingCompleteListener
Parameters:
event - A SentenceProcessingCompleteEvent object describing the event source.

getWorkQueueSize

public int getWorkQueueSize()
Get the size of the sentence production queue.

Returns:
The size of the queue.

setWorkQueueSize

public void setWorkQueueSize(int size)
Set the size of the sentence production queue.

Parameters:
size - The size of the queue.

Textractor API textractor-720 (20091120123250)

Copyright © 2003-2008 Institute for Computational Biomedicine, All Rights Reserved.