Package adams.flow.control
Class FileProcessor
-
- All Implemented Interfaces:
AdditionalInformationHandler
,AtomicMoveSupporter
,CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,QuickInfoSupporter
,ShallowCopySupporter<Actor>
,SizeOfHandler
,Stoppable
,StoppableWithFeedback
,VariablesInspectionHandler
,VariableChangeListener
,Actor
,ActorHandler
,ControlActor
,ErrorHandler
,Flushable
,InputConsumer
,MutableActorHandler
,OutputProducer
,Serializable
,Comparable
public class FileProcessor extends AbstractDataProcessor implements MutableActorHandler, ControlActor
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Sequence
m_Actors
the flow items.protected Actor
m_Input
the actor to use for input.protected boolean
m_UseFiles
whether to use files or strings as input for the actors.-
Fields inherited from class adams.flow.transformer.AbstractDataProcessor
m_AtomicMove, m_DestinationFile, m_Failed, m_Processed, m_ProcessError, m_Processing, m_TimestampDirFormat, m_UseTimestampDirs
-
Fields inherited from class adams.flow.transformer.AbstractTransformer
BACKUP_INPUT, BACKUP_OUTPUT, m_InputToken, m_OutputToken
-
Fields inherited from class adams.flow.core.AbstractActor
m_Annotations, m_BackupState, m_DetectedObjectVariables, m_DetectedVariables, m_ErrorHandler, m_Executed, m_Executing, m_ExecutionListeningSupporter, m_FullName, m_LoggingPrefix, m_Name, m_Parent, m_ScopeHandler, m_Self, m_Silent, m_Skip, m_StopFlowOnError, m_StopMessage, m_Stopped, m_StorageHandler, m_VariablesUpdated
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
Fields inherited from interface adams.flow.core.Actor
FILE_EXTENSION, FILE_EXTENSION_GZ
-
-
Constructor Summary
Constructors Constructor Description FileProcessor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
actorsTipText()
Returns the tip text for this property.String
add(int index, Actor actor)
Inserts the actor at the given position.String
add(Actor actor)
Inserts the actor at the end.String
check()
Performs checks on the "sub-actors".protected String
checkSubActor(int index, Actor actor)
Checks the tee actor before it is set.protected String
checkSubActors(Actor[] actors)
Checks the tee actors before they are set via the setTeeActors method.void
cleanUp()
Cleans up after the execution has finished.void
defineOptions()
Adds options to the internal list of options.Actor
firstActive()
Returns the first non-skipped actor.void
flushExecution()
Stops the processing of tokens without stopping the flow.Class[]
generates()
Returns the class of objects that it generates.Actor
get(int index)
Returns the actor at the given position.ActorHandlerInfo
getActorHandlerInfo()
Returns some information about the actor handler, e.g., whether it can contain standalones and the actor execution.Actor[]
getActors()
Returns the actors to tee-off to.String
globalInfo()
Returns a string describing the object.int
indexOf(String actor)
Returns the index of the actor.protected void
initialize()
Initializes the members.Actor
lastActive()
Returns the last non-skipped actor.protected boolean
processData(File file)
Processes the given data.Actor
remove(int index)
Removes the actor at the given position and returns the removed object.void
removeAll()
Removes all actors.protected void
reset()
Resets the actor.String
set(int index, Actor actor)
Sets the actor at the given position.void
setActors(Actor[] value)
Sets the actor to tee-off to.void
setLoggingLevel(LoggingLevel value)
Sets the logging level.String
setUp()
Initializes the item for flow execution.protected String
setUpSubActors()
Performs the setUp of the sub-actors.int
size()
Returns the size of the group.void
stopExecution()
Stops the execution.protected void
updateParent()
Updates the parent of all actors in this group.void
wrapUp()
Finishes up the execution.-
Methods inherited from class adams.flow.transformer.AbstractDataProcessor
accepts, atomicMoveTipText, doExecute, failedTipText, getAtomicMove, getFailed, getProcessed, getProcessing, getUseTimestampDirs, nextTimestampDir, postProcessData, prepareData, processedTipText, processingTipText, setAtomicMove, setFailed, setProcessed, setProcessing, setUseTimestampDirs, useTimestampDirsTipText
-
Methods inherited from class adams.flow.transformer.AbstractTransformer
backupState, currentInput, execute, hasInput, hasPendingOutput, input, output, postExecute, restoreState
-
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, canInspectOptions, canPerformSetUpCheck, compareTo, configureLogger, destroy, equals, finalUpdateVariables, findVariables, findVariables, forceVariables, forCommandLine, forName, forName, getAdditionalInformation, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowActors, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getQuickInfo, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, handleException, hasErrorHandler, hasStopMessage, index, isBackedUp, isExecuted, isExecuting, isFinished, isHeadless, isStopped, nameTipText, performSetUpChecks, performVariableChecks, preExecute, pruneBackup, pruneBackup, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setVariables, shallowCopy, shallowCopy, silentTipText, sizeOf, skipTipText, stopExecution, stopFlowOnErrorTipText, updateDetectedVariables, updatePrefix, updateVariables, variableChanged
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.flow.core.Actor
compareTo, destroy, equals, execute, findVariables, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getQuickInfo, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, hasErrorHandler, hasStopMessage, index, isExecuted, isFinished, isHeadless, isStopped, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setVariables, shallowCopy, shallowCopy, sizeOf, stopExecution, toCommandLine, variableChanged
-
Methods inherited from interface adams.core.AdditionalInformationHandler
getAdditionalInformation
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.logging.LoggingSupporter
getLogger, isLoggingEnabled
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager
-
Methods inherited from interface adams.core.VariablesInspectionHandler
canInspectOptions
-
-
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceGlobalInfoSupporter
- Specified by:
globalInfo
in classAbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractDataProcessor
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classAbstractDataProcessor
-
reset
protected void reset()
Resets the actor.- Overrides:
reset
in classAbstractActor
-
setLoggingLevel
public void setLoggingLevel(LoggingLevel value)
Sets the logging level.- Specified by:
setLoggingLevel
in interfaceLoggingLevelHandler
- Overrides:
setLoggingLevel
in classAbstractOptionHandler
- Parameters:
value
- the level
-
updateParent
protected void updateParent()
Updates the parent of all actors in this group.
-
checkSubActor
protected String checkSubActor(int index, Actor actor)
Checks the tee actor before it is set. Returns an error message if the actor is not acceptable, null otherwise.- Parameters:
index
- the index the actor gets setactor
- the actor to check- Returns:
- null if accepted, otherwise error message
-
checkSubActors
protected String checkSubActors(Actor[] actors)
Checks the tee actors before they are set via the setTeeActors method. Returns an error message if the actors are not acceptable, null otherwise.- Parameters:
actors
- the actors to check- Returns:
- null if accepted, otherwise error message
-
setActors
public void setActors(Actor[] value)
Sets the actor to tee-off to.- Parameters:
value
- the actor
-
getActors
public Actor[] getActors()
Returns the actors to tee-off to.- Returns:
- the actors
-
actorsTipText
public String actorsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getActorHandlerInfo
public ActorHandlerInfo getActorHandlerInfo()
Returns some information about the actor handler, e.g., whether it can contain standalones and the actor execution.- Specified by:
getActorHandlerInfo
in interfaceActorHandler
- Returns:
- the info
-
check
public String check()
Performs checks on the "sub-actors".- Specified by:
check
in interfaceActorHandler
- Returns:
- null if everything is fine, otherwise the error
-
size
public int size()
Description copied from interface:ActorHandler
Returns the size of the group.- Specified by:
size
in interfaceActorHandler
- Returns:
- the size
-
get
public Actor get(int index)
Returns the actor at the given position.- Specified by:
get
in interfaceActorHandler
- Parameters:
index
- the position- Returns:
- the actor
-
set
public String set(int index, Actor actor)
Sets the actor at the given position.- Specified by:
set
in interfaceActorHandler
- Parameters:
index
- the positionactor
- the actor to set at this position- Returns:
- null if successful, otherwise error message
-
indexOf
public int indexOf(String actor)
Returns the index of the actor.- Specified by:
indexOf
in interfaceActorHandler
- Parameters:
actor
- the name of the actor to look for- Returns:
- the index of -1 if not found
-
firstActive
public Actor firstActive()
Returns the first non-skipped actor.- Specified by:
firstActive
in interfaceActorHandler
- Returns:
- the first 'active' actor, null if none available
-
lastActive
public Actor lastActive()
Returns the last non-skipped actor.- Specified by:
lastActive
in interfaceActorHandler
- Returns:
- the last 'active' actor, null if none available
-
generates
public Class[] generates()
Returns the class of objects that it generates.- Specified by:
generates
in interfaceOutputProducer
- Returns:
- the Class of the generated tokens
-
add
public String add(Actor actor)
Inserts the actor at the end.- Specified by:
add
in interfaceMutableActorHandler
- Parameters:
actor
- the actor to insert- Returns:
- null if successful, otherwise error message
-
add
public String add(int index, Actor actor)
Inserts the actor at the given position.- Specified by:
add
in interfaceMutableActorHandler
- Parameters:
index
- the positionactor
- the actor to insert- Returns:
- null if successful, otherwise error message
-
remove
public Actor remove(int index)
Removes the actor at the given position and returns the removed object.- Specified by:
remove
in interfaceMutableActorHandler
- Parameters:
index
- the position- Returns:
- the removed actor
-
removeAll
public void removeAll()
Removes all actors.- Specified by:
removeAll
in interfaceMutableActorHandler
-
setUpSubActors
protected String setUpSubActors()
Performs the setUp of the sub-actors.- Returns:
- null if everything is fine, otherwise error message
-
setUp
public String setUp()
Initializes the item for flow execution.- Specified by:
setUp
in interfaceActor
- Overrides:
setUp
in classAbstractActor
- Returns:
- null if everything is fine, otherwise error message
- See Also:
AbstractActor.reset()
-
processData
protected boolean processData(File file)
Processes the given data.- Specified by:
processData
in classAbstractDataProcessor
- Parameters:
file
- the file/dir to process- Returns:
- true if everything went alright
- See Also:
AbstractDataProcessor.m_ProcessError
-
flushExecution
public void flushExecution()
Stops the processing of tokens without stopping the flow.- Specified by:
flushExecution
in interfaceActorHandler
- Specified by:
flushExecution
in interfaceFlushable
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecution
in interfaceActor
- Specified by:
stopExecution
in interfaceStoppable
- Overrides:
stopExecution
in classAbstractActor
-
wrapUp
public void wrapUp()
Finishes up the execution.- Specified by:
wrapUp
in interfaceActor
- Overrides:
wrapUp
in classAbstractTransformer
-
cleanUp
public void cleanUp()
Cleans up after the execution has finished. Also removes graphical components.- Specified by:
cleanUp
in interfaceActor
- Specified by:
cleanUp
in interfaceCleanUpHandler
- Overrides:
cleanUp
in classAbstractActor
-
-