org.carrot2.core.impl
Class ArrayOutputComponent

java.lang.Object
  extended by org.carrot2.core.LocalComponentBase
      extended by org.carrot2.core.LocalOutputComponentBase
          extended by org.carrot2.core.impl.ArrayOutputComponent
All Implemented Interfaces:
RawClustersConsumer, RawDocumentsConsumer, LocalComponent, LocalOutputComponent

public class ArrayOutputComponent
extends LocalOutputComponentBase
implements LocalOutputComponent, RawClustersConsumer, RawDocumentsConsumer

A utility implementation of an output component that implements RawClustersConsumer and RawDocumentsConsumer interfaces and collects RawCluster objects and RawDocument objects to two arrays returned as the result of a process.

Version:
$Revision: 2122 $
Author:
Dawid Weiss

Nested Class Summary
static class ArrayOutputComponent.Result
          An class that stores documents and clusters collected during the processing of a query.
 
Constructor Summary
ArrayOutputComponent()
           
 
Method Summary
 void addCluster(RawCluster cluster)
          Adds a cluster to the list of clusters to be returned as the result.
 void addDocument(RawDocument doc)
          Adds a document to the list of documents to be returned as the result.
 void endProcessing()
          Provides an empty implementation
 void flushResources()
          Clears clusters and documents lists and prepares the component for reuse.
 Set getComponentCapabilities()
          Provides an implementation that has no capabilities (an empty set).
 Set getRequiredPredecessorCapabilities()
          Provides an implementation that requires no capabilities of the predecessor component.
 Object getResult()
           
 void startProcessing(RequestContext requestContext)
          Provides an empty implementation.
 
Methods inherited from class org.carrot2.core.LocalOutputComponentBase
processingErrorOccurred, validate
 
Methods inherited from class org.carrot2.core.LocalComponentBase
getDescription, getIntFromRequestContext, getName, getProperty, getRequiredSuccessorCapabilities, init, setProperty, toSet, toSet, toSet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.carrot2.core.LocalComponent
getDescription, getName, getRequiredSuccessorCapabilities, init, processingErrorOccurred, setProperty
 

Constructor Detail

ArrayOutputComponent

public ArrayOutputComponent()
Method Detail

getResult

public Object getResult()
Specified by:
getResult in interface LocalOutputComponent
Returns:
Returns an instance of ArrayOutputComponent.Result with documents and clusters collected during the query execution.

startProcessing

public void startProcessing(RequestContext requestContext)
                     throws ProcessingException
Provides an empty implementation.

Specified by:
startProcessing in interface LocalComponent
Overrides:
startProcessing in class LocalOutputComponentBase
Parameters:
requestContext - A RequestContextinterface instance passed by the container processing the query. The context may be used to retrieve parameters associated with the query (see RequestContext.getRequestParameters() method).
Throws:
ProcessingException - Thrown if the component encountered a problem in processing the query. May also be thrown from a chained successor component.

endProcessing

public void endProcessing()
                   throws ProcessingException
Provides an empty implementation

Specified by:
endProcessing in interface LocalComponent
Overrides:
endProcessing in class LocalOutputComponentBase
Throws:
ProcessingException - Thrown if the component encountered a problem in processing the query. May also be thrown from a chained successor component. It is allowed to throw an exception and not invoke endProcessing() method on subsequent components. In such case, all components will receive a LocalComponent.processingErrorOccurred()call.

addCluster

public void addCluster(RawCluster cluster)
                throws ProcessingException
Adds a cluster to the list of clusters to be returned as the result.

Specified by:
addCluster in interface RawClustersConsumer
Parameters:
cluster - A new RawCluster passed from the predecessor component.
Throws:
ProcessingException - Thrown if this component cannot accept the cluster reference for some reason.

addDocument

public void addDocument(RawDocument doc)
                 throws ProcessingException
Adds a document to the list of documents to be returned as the result.

Specified by:
addDocument in interface RawDocumentsConsumer
Parameters:
doc - A new RawDocument object passed from the predecessor component.
Throws:
ProcessingException - Thrown if this component cannot accept the document reference for some reason.

flushResources

public void flushResources()
Clears clusters and documents lists and prepares the component for reuse.

Specified by:
flushResources in interface LocalComponent
Overrides:
flushResources in class LocalOutputComponentBase

getComponentCapabilities

public Set getComponentCapabilities()
Description copied from class: LocalComponentBase
Provides an implementation that has no capabilities (an empty set).

Specified by:
getComponentCapabilities in interface LocalComponent
Overrides:
getComponentCapabilities in class LocalComponentBase
Returns:
A Setobject with capabilities. The object returned may be empty, but should never be null.
See Also:
LocalComponent.getComponentCapabilities()

getRequiredPredecessorCapabilities

public Set getRequiredPredecessorCapabilities()
Description copied from class: LocalComponentBase
Provides an implementation that requires no capabilities of the predecessor component.

Specified by:
getRequiredPredecessorCapabilities in interface LocalComponent
Overrides:
getRequiredPredecessorCapabilities in class LocalComponentBase
Returns:
A Setobject with capabilities. The object returned may be empty, but should never be null.
See Also:
LocalComponent.getRequiredPredecessorCapabilities()


Copyright (c) Dawid Weiss, Stanislaw Osinski