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 StringBACKUP_BUFFERthe key for storing the buffer in the backup.protected intm_AttemptIntervalthe interval between attempts.protected List<String>m_Bufferthe buffer.protected intm_BufferSizethe size of the buffer.protected BaseCharsetm_Encodingthe encoding to use.protected intm_NumAttemptsthe number of tries for writing the data.protected booleanm_Writingwhether 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.StringappendTipText()Returns the tip text for this property.StringattemptIntervalTipText()Returns the tip text for this property.protected Hashtable<String,Object>backupState()Backs up the current state of the actor before update the variables.StringbufferSizeTipText()Returns the tip text for this property.voiddefineOptions()Adds options to the internal list of options.protected StringdoExecute()Executes the flow item.StringencodingTipText()Returns the tip text for this property.intgetAttemptInterval()Returns the time to wait between attempts in msec.intgetBufferSize()Returns the number of lines to buffer before writing them to disk.BaseCharsetgetEncoding()Returns the encoding to use.intgetNumAttempts()Returns the number of attempts.StringgetQuickInfo()Returns a quick info about the actor, which will be displayed in the GUI.StringglobalInfo()Returns a string describing the object.protected voidinitialize()Initializes the members.StringnumAttemptsTipText()Returns the tip text for this property.StringoutputFileTipText()Returns the tip text for this property.voidperformFlush()Performs the flush.protected voidreset()Resets the scheme.protected voidrestoreState(Hashtable<String,Object> state)Restores the state of the actor before the variables got updated.voidsetAttemptInterval(int value)Sets the time to wait between attempts in msec.voidsetBufferSize(int value)Sets the number of lines to buffer before writing them to disk.voidsetEncoding(BaseCharset value)Sets the encoding to use.voidsetNumAttempts(int value)Sets the number of attempts.protected StringupdateVariables()Gets called when the actor needs to be re-setUp when a variable changes.voidwrapUp()Cleans up after the execution has finished.protected StringwriteToDisk()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:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractAppendableFileWriter
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein classAbstractActor
-
reset
protected void reset()
Resets the scheme.- Overrides:
resetin classAbstractActor
-
outputFileTipText
public String outputFileTipText()
Returns the tip text for this property.- Specified by:
outputFileTipTextin interfaceFileWriter- Specified by:
outputFileTipTextin 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:
appendTipTextin 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:
setEncodingin 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:
getEncodingin 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:
encodingTipTextin 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:
setNumAttemptsin interfaceMultiAttemptSupporter- Parameters:
value- the number of attempts
-
getNumAttempts
public int getNumAttempts()
Returns the number of attempts.- Specified by:
getNumAttemptsin interfaceMultiAttemptSupporter- Returns:
- the number of attempts
-
numAttemptsTipText
public String numAttemptsTipText()
Returns the tip text for this property.- Specified by:
numAttemptsTipTextin 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:
setAttemptIntervalin interfaceMultiAttemptWithWaitSupporter- Parameters:
value- the time in msec
-
getAttemptInterval
public int getAttemptInterval()
Returns the time to wait between attempts in msec.- Specified by:
getAttemptIntervalin interfaceMultiAttemptWithWaitSupporter- Returns:
- the time in msec
-
attemptIntervalTipText
public String attemptIntervalTipText()
Returns the tip text for this property.- Specified by:
attemptIntervalTipTextin 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:
setBufferSizein 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:
getBufferSizein interfaceBufferSupporter- Returns:
- the number of lines to buffer
-
bufferSizeTipText
public String bufferSizeTipText()
Returns the tip text for this property.- Specified by:
bufferSizeTipTextin 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:
getQuickInfoin interfaceActor- Specified by:
getQuickInfoin interfaceQuickInfoSupporter- Overrides:
getQuickInfoin 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:
backupStatein 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:
restoreStatein 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:
acceptsin 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:
updateVariablesin classAbstractActor- Returns:
- null if everything is fine, otherwise error message
-
doExecute
protected String doExecute()
Executes the flow item.- Specified by:
doExecutein classAbstractActor- Returns:
- null if everything is fine, otherwise error message
-
wrapUp
public void wrapUp()
Cleans up after the execution has finished.- Specified by:
wrapUpin interfaceActor- Overrides:
wrapUpin classAbstractSink
-
performFlush
public void performFlush()
Performs the flush.- Specified by:
performFlushin interfaceFlushSupporter
-
-