Class XPipeline
- java.lang.Object
-
- net.sf.okapi.common.pipeline.Pipeline
-
- net.sf.okapi.common.pipelinebuilder.XPipeline
-
- All Implemented Interfaces:
AutoCloseable,Function<Stream<Event>,Stream<Event>>,IObservable,IObserver,IPipeline,IPipelineStep
public class XPipeline extends Pipeline implements IPipelineStep
-
-
Field Summary
-
Fields inherited from class net.sf.okapi.common.pipeline.Pipeline
DEFAULT_ID
-
-
Constructor Summary
Constructors Constructor Description XPipeline(String description, IPipeline pipeline)XPipeline(String description, IPipelineStep... steps)XPipeline(String description, XBatch batch, IPipelineStep... steps)XPipeline(String description, XBatch batch, XPipelineType type, IPipelineStep... steps)XPipeline(String description, XFilters filters, String rootDir, XBatch batch, IPipelineStep... steps)XPipeline(String description, XFilters filters, XBatch batch, IPipelineStep... steps)XPipeline(String description, XPipelineType type, IPipelineStep... steps)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddObserver(IObserver observer)Attaches a observer to the Observable.intcountObservers()Counts how many Observers were attached to this class.voiddeleteObserver(IObserver observer)Detaches a previously attached observer to the observable.voiddeleteObservers()Detaches all previously attached observer to the observable.PipelineReturnValueexecute()XBatchgetBatch()StringgetDescription()Gets a short localizable description of what this step does.StringgetHelpLocation()Gets the relative directory location for the help of this step.StringgetName()Gets the localizable name of this step.List<IObserver>getObservers()Returns list of observers registered with the Observable.IParametersgetParameters()Gets the current parameters for this step.EventhandleEvent(Event event)Processes each event sent though the pipeline.booleanisDone()booleanisLastOutputStep()Is this step the last step with output in the pipeline?voidnotifyObservers()Notifies all attached observers about changes in the observable.voidnotifyObservers(Object arg)Notifies all attached observers about changes in the observable.voidsetBatch(XBatch batch)voidsetLastOutputStep(boolean isLastStep)Tell the step if it is the last one on the pipeline with output.voidsetParameters(IParameters params)Sets new parameters for this step.voidstop()-
Methods inherited from class net.sf.okapi.common.pipeline.Pipeline
addStep, cancel, clearSteps, destroy, endBatch, getId, getState, getSteps, process, process, setId, startBatch, update
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sf.okapi.common.pipeline.IPipelineStep
apply, cancel, close, destroy, getSourceLocale, getTargetLocale, handleStream, setSourceLocale, setTargetLocale
-
-
-
-
Constructor Detail
-
XPipeline
public XPipeline(String description, IPipelineStep... steps)
-
XPipeline
public XPipeline(String description, XPipelineType type, IPipelineStep... steps)
-
XPipeline
public XPipeline(String description, XBatch batch, IPipelineStep... steps)
-
XPipeline
public XPipeline(String description, XFilters filters, XBatch batch, IPipelineStep... steps)
-
XPipeline
public XPipeline(String description, XFilters filters, String rootDir, XBatch batch, IPipelineStep... steps)
-
XPipeline
public XPipeline(String description, XBatch batch, XPipelineType type, IPipelineStep... steps)
-
-
Method Detail
-
execute
public PipelineReturnValue execute()
-
stop
public void stop()
-
getHelpLocation
public String getHelpLocation()
Description copied from interface:IPipelineStepGets the relative directory location for the help of this step. The main help file for the step must be at that location and its name must be the name of the class implementing the step in lowercase with a .html extension.- Specified by:
getHelpLocationin interfaceIPipelineStep- Returns:
- the relative directory location for the help of this step.
-
getName
public String getName()
Description copied from interface:IPipelineStepGets the localizable name of this step.- Specified by:
getNamein interfaceIPipelineStep- Returns:
- the localizable name of this step.
-
getParameters
public IParameters getParameters()
Description copied from interface:IPipelineStepGets the current parameters for this step.- Specified by:
getParametersin interfaceIPipelineStep- Returns:
- the current parameters for this step or null if there are no parameters.
-
handleEvent
public Event handleEvent(Event event)
Description copied from interface:IPipelineStepProcesses each event sent though the pipeline.- Specified by:
handleEventin interfaceIPipelineStep- Parameters:
event- the event to process.- Returns:
- the event to pass down the pipeline.
-
isDone
public boolean isDone()
Description copied from interface:IPipelineStepSteps that can generateEvents such asIFilters return false until no more events can be created. Steps which do not createEvents always return true.- Specified by:
isDonein interfaceIPipelineStep- Returns:
- false if can generate more events, true otherwise.
-
isLastOutputStep
public boolean isLastOutputStep()
Description copied from interface:IPipelineStepIs this step the last step with output in the pipeline?- Specified by:
isLastOutputStepin interfaceIPipelineStep- Returns:
- true if last step with output, false otherwise.
-
setLastOutputStep
public void setLastOutputStep(boolean isLastStep)
Description copied from interface:IPipelineStepTell the step if it is the last one on the pipeline with output.- Specified by:
setLastOutputStepin interfaceIPipelineStep- Parameters:
isLastStep- true if last step with output, false otherwise.
-
setParameters
public void setParameters(IParameters params)
Description copied from interface:IPipelineStepSets new parameters for this step.- Specified by:
setParametersin interfaceIPipelineStep- Parameters:
params- the new parameters to use.
-
getBatch
public XBatch getBatch()
-
setBatch
public void setBatch(XBatch batch)
-
getDescription
public String getDescription()
Description copied from interface:IPipelineStepGets a short localizable description of what this step does.- Specified by:
getDescriptionin interfaceIPipelineStep- Returns:
- the text of a short description of what this step does.
-
addObserver
public void addObserver(IObserver observer)
Description copied from interface:IObservableAttaches a observer to the Observable. After attachment the observer gets informed about changes in the Observable.- Specified by:
addObserverin interfaceIObservable- Overrides:
addObserverin classPipeline- Parameters:
observer- The observer to attach to the observable
-
countObservers
public int countObservers()
Description copied from interface:IObservableCounts how many Observers were attached to this class.- Specified by:
countObserversin interfaceIObservable- Overrides:
countObserversin classPipeline- Returns:
- the number of Observers
- See Also:
IObserver
-
deleteObserver
public void deleteObserver(IObserver observer)
Description copied from interface:IObservableDetaches a previously attached observer to the observable. After detachment the observer does no longer receive change notifications from the observable.- Specified by:
deleteObserverin interfaceIObservable- Overrides:
deleteObserverin classPipeline- Parameters:
observer- The observer to detach from the observable
-
notifyObservers
public void notifyObservers()
Description copied from interface:IObservableNotifies all attached observers about changes in the observable.- Specified by:
notifyObserversin interfaceIObservable- Overrides:
notifyObserversin classPipeline
-
notifyObservers
public void notifyObservers(Object arg)
Description copied from interface:IObservableNotifies all attached observers about changes in the observable.- Specified by:
notifyObserversin interfaceIObservable- Overrides:
notifyObserversin classPipeline- Parameters:
arg- an arbitrary Object to be passed to the Observer
-
deleteObservers
public void deleteObservers()
Description copied from interface:IObservableDetaches all previously attached observer to the observable. After detachment observers do not longer receive change notifications from the observable.- Specified by:
deleteObserversin interfaceIObservable- Overrides:
deleteObserversin classPipeline
-
getObservers
public List<IObserver> getObservers()
Description copied from interface:IObservableReturns list of observers registered with the Observable. List returned is unmodifiable list.- Specified by:
getObserversin interfaceIObservable- Overrides:
getObserversin classPipeline- Returns:
- list of observers
-
-