Package adams.flow.sink
Class DumpFile
-
- All Implemented Interfaces:
AdditionalInformationHandler
,BufferSupporter
,CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,EncodingSupporter
,FileWriter
,LoggingLevelHandler
,LoggingSupporter
,MultiAttemptSupporter
,MultiAttemptWithWaitSupporter
,OptionHandler
,QuickInfoSupporter
,ShallowCopySupporter<Actor>
,SizeOfHandler
,Stoppable
,StoppableWithFeedback
,VariablesInspectionHandler
,VariableChangeListener
,Actor
,ErrorHandler
,FlushSupporter
,InputConsumer
,Serializable
,Comparable
public class DumpFile extends AbstractAppendableFileWriter implements EncodingSupporter, MultiAttemptWithWaitSupporter, BufferSupporter, FlushSupporter
Actor that just dumps any input token into a separate line of the specified output file.
Input/output:
- accepts:
adams.flow.core.Unknown
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-name <java.lang.String> (property: name) The name of the actor. default: DumpFile
-annotation <adams.core.base.BaseAnnotation> (property: annotations) The annotations to attach to this actor. default:
-skip <boolean> (property: skip) If set to true, transformation is skipped and the input token is just forwarded as it is. default: false
-stop-flow-on-error <boolean> (property: stopFlowOnError) If set to true, the flow gets stopped in case this actor encounters an error; useful for critical actors. default: false
-silent <boolean> (property: silent) If enabled, then no errors are output in the console. default: false
-output <adams.core.io.PlaceholderFile> (property: outputFile) The name of the output file. default: ${CWD}
-append <boolean> (property: append) If set to true, file gets only appended. default: false
-encoding <adams.core.base.BaseCharset> (property: encoding) The type of encoding to use when writing to the file, use empty string for default. default: Default
-num-attempts <int> (property: numAttempts) The number of attempts for writing the data. default: 1 minimum: 1
-attempt-interval <int> (property: attemptInterval) The time in msec to wait before the next attempt. default: 1000 minimum: 0
-buffer-size <int> (property: bufferSize) The number of lines to buffer before writing to disk, in order to improve I/O performance. default: 1 minimum: 1
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
BACKUP_BUFFER
the key for storing the buffer in the backup.protected int
m_AttemptInterval
the interval between attempts.protected List<String>
m_Buffer
the buffer.protected int
m_BufferSize
the size of the buffer.protected BaseCharset
m_Encoding
the encoding to use.protected int
m_NumAttempts
the number of tries for writing the data.protected boolean
m_Writing
whether currently writing to disk.-
Fields inherited from class adams.flow.sink.AbstractAppendableFileWriter
m_Append
-
Fields inherited from class adams.flow.sink.AbstractFileWriter
m_OutputFile
-
Fields inherited from class adams.flow.sink.AbstractSink
BACKUP_INPUT, m_InputToken
-
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 DumpFile()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Class[]
accepts()
Returns the class that the consumer accepts.String
appendTipText()
Returns the tip text for this property.String
attemptIntervalTipText()
Returns the tip text for this property.protected Hashtable<String,Object>
backupState()
Backs up the current state of the actor before update the variables.String
bufferSizeTipText()
Returns the tip text for this property.void
defineOptions()
Adds options to the internal list of options.protected String
doExecute()
Executes the flow item.String
encodingTipText()
Returns the tip text for this property.int
getAttemptInterval()
Returns the time to wait between attempts in msec.int
getBufferSize()
Returns the number of lines to buffer before writing them to disk.BaseCharset
getEncoding()
Returns the encoding to use.int
getNumAttempts()
Returns the number of attempts.String
getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.String
globalInfo()
Returns a string describing the object.protected void
initialize()
Initializes the members.String
numAttemptsTipText()
Returns the tip text for this property.String
outputFileTipText()
Returns the tip text for this property.void
performFlush()
Performs the flush.protected void
reset()
Resets the scheme.protected void
restoreState(Hashtable<String,Object> state)
Restores the state of the actor before the variables got updated.void
setAttemptInterval(int value)
Sets the time to wait between attempts in msec.void
setBufferSize(int value)
Sets the number of lines to buffer before writing them to disk.void
setEncoding(BaseCharset value)
Sets the encoding to use.void
setNumAttempts(int value)
Sets the number of attempts.protected String
updateVariables()
Gets called when the actor needs to be re-setUp when a variable changes.void
wrapUp()
Cleans up after the execution has finished.protected String
writeToDisk()
Writes the content of the buffer to disk.-
Methods inherited from class adams.flow.sink.AbstractAppendableFileWriter
getAppend, setAppend
-
Methods inherited from class adams.flow.sink.AbstractFileWriter
getDefaultOutputFile, getOutputFile, setOutputFile, setUp
-
Methods inherited from class adams.flow.sink.AbstractSink
currentInput, hasInput, input, postExecute
-
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, canInspectOptions, canPerformSetUpCheck, cleanUp, compareTo, configureLogger, destroy, equals, execute, finalUpdateVariables, findVariables, findVariables, forceVariables, forCommandLine, forName, forName, getAdditionalInformation, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowActors, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, 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, stopExecution, stopFlowOnErrorTipText, updateDetectedVariables, updatePrefix, variableChanged
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, setLoggingLevel, 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
cleanUp, compareTo, destroy, equals, execute, findVariables, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, hasErrorHandler, hasStopMessage, index, isExecuted, isFinished, isHeadless, isStopped, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setUp, setVariables, shallowCopy, shallowCopy, sizeOf, stopExecution, stopExecution, toCommandLine, variableChanged
-
Methods inherited from interface adams.core.AdditionalInformationHandler
getAdditionalInformation
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel, setLoggingLevel
-
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
-
-
-
-
Field Detail
-
BACKUP_BUFFER
public static final String BACKUP_BUFFER
the key for storing the buffer in the backup.- See Also:
- Constant Field Values
-
m_Encoding
protected BaseCharset m_Encoding
the encoding to use.
-
m_NumAttempts
protected int m_NumAttempts
the number of tries for writing the data.
-
m_AttemptInterval
protected int m_AttemptInterval
the interval between attempts.
-
m_BufferSize
protected int m_BufferSize
the size of the buffer.
-
m_Writing
protected boolean m_Writing
whether currently writing to disk.
-
-
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 classAbstractAppendableFileWriter
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classAbstractActor
-
reset
protected void reset()
Resets the scheme.- Overrides:
reset
in classAbstractActor
-
outputFileTipText
public String outputFileTipText()
Returns the tip text for this property.- Specified by:
outputFileTipText
in interfaceFileWriter
- Specified by:
outputFileTipText
in classAbstractFileWriter
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
appendTipText
public String appendTipText()
Returns the tip text for this property.- Specified by:
appendTipText
in classAbstractAppendableFileWriter
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setEncoding
public void setEncoding(BaseCharset value)
Sets the encoding to use.- Specified by:
setEncoding
in interfaceEncodingSupporter
- Parameters:
value
- the encoding, e.g. "UTF-8" or "UTF-16", empty string for default
-
getEncoding
public BaseCharset getEncoding()
Returns the encoding to use.- Specified by:
getEncoding
in interfaceEncodingSupporter
- Returns:
- the encoding, e.g. "UTF-8" or "UTF-16", empty string for default
-
encodingTipText
public String encodingTipText()
Returns the tip text for this property.- Specified by:
encodingTipText
in interfaceEncodingSupporter
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setNumAttempts
public void setNumAttempts(int value)
Sets the number of attempts.- Specified by:
setNumAttempts
in interfaceMultiAttemptSupporter
- Parameters:
value
- the number of attempts
-
getNumAttempts
public int getNumAttempts()
Returns the number of attempts.- Specified by:
getNumAttempts
in interfaceMultiAttemptSupporter
- Returns:
- the number of attempts
-
numAttemptsTipText
public String numAttemptsTipText()
Returns the tip text for this property.- Specified by:
numAttemptsTipText
in interfaceMultiAttemptSupporter
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setAttemptInterval
public void setAttemptInterval(int value)
Sets the time to wait between attempts in msec.- Specified by:
setAttemptInterval
in interfaceMultiAttemptWithWaitSupporter
- Parameters:
value
- the time in msec
-
getAttemptInterval
public int getAttemptInterval()
Returns the time to wait between attempts in msec.- Specified by:
getAttemptInterval
in interfaceMultiAttemptWithWaitSupporter
- Returns:
- the time in msec
-
attemptIntervalTipText
public String attemptIntervalTipText()
Returns the tip text for this property.- Specified by:
attemptIntervalTipText
in interfaceMultiAttemptWithWaitSupporter
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setBufferSize
public void setBufferSize(int value)
Sets the number of lines to buffer before writing them to disk.- Specified by:
setBufferSize
in interfaceBufferSupporter
- Parameters:
value
- the number of lines to buffer
-
getBufferSize
public int getBufferSize()
Returns the number of lines to buffer before writing them to disk.- Specified by:
getBufferSize
in interfaceBufferSupporter
- Returns:
- the number of lines to buffer
-
bufferSizeTipText
public String bufferSizeTipText()
Returns the tip text for this property.- Specified by:
bufferSizeTipText
in interfaceBufferSupporter
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.- Specified by:
getQuickInfo
in interfaceActor
- Specified by:
getQuickInfo
in interfaceQuickInfoSupporter
- Overrides:
getQuickInfo
in classAbstractAppendableFileWriter
- Returns:
- null if no info available, otherwise short string
-
backupState
protected Hashtable<String,Object> backupState()
Backs up the current state of the actor before update the variables.- Overrides:
backupState
in classAbstractSink
- Returns:
- the backup
- See Also:
AbstractActor.updateVariables()
,AbstractActor.restoreState(Hashtable)
-
restoreState
protected void restoreState(Hashtable<String,Object> state)
Restores the state of the actor before the variables got updated.- Overrides:
restoreState
in classAbstractSink
- Parameters:
state
- the backup of the state to restore from- See Also:
AbstractActor.updateVariables()
,AbstractActor.backupState()
-
accepts
public Class[] accepts()
Returns the class that the consumer accepts.- Specified by:
accepts
in interfaceInputConsumer
- Returns:
- adams.flow.core.Unknown.class
-
writeToDisk
protected String writeToDisk()
Writes the content of the buffer to disk.- Returns:
- error message is something went wrong, null otherwise
-
updateVariables
protected String updateVariables()
Gets called when the actor needs to be re-setUp when a variable changes.- Overrides:
updateVariables
in classAbstractActor
- Returns:
- null if everything is fine, otherwise error message
-
doExecute
protected String doExecute()
Executes the flow item.- Specified by:
doExecute
in classAbstractActor
- Returns:
- null if everything is fine, otherwise error message
-
wrapUp
public void wrapUp()
Cleans up after the execution has finished.- Specified by:
wrapUp
in interfaceActor
- Overrides:
wrapUp
in classAbstractSink
-
performFlush
public void performFlush()
Performs the flush.- Specified by:
performFlush
in interfaceFlushSupporter
-
-