Class MoveFile

  • All Implemented Interfaces:
    AdditionalInformationHandler, AtomicMoveSupporter, CleanUpHandler, Destroyable, GlobalInfoSupporter, LoggingLevelHandler, LoggingSupporter, MultiAttemptSupporter, MultiAttemptWithWaitSupporter, OptionHandler, QuickInfoSupporter, ShallowCopySupporter<Actor>, SizeOfHandler, Stoppable, StoppableWithFeedback, VariablesInspectionHandler, VariableChangeListener, Actor, ErrorHandler, InputConsumer, OutputProducer, Serializable, Comparable

    public class MoveFile
    extends AbstractTransformer
    implements MultiAttemptWithWaitSupporter, AtomicMoveSupporter
    Moves a file to a different location (or just renames it).
    Source and target can be swapped as well.
    Simply forwards the input token if moving was successful.

    Input/output:
    - accepts:
       java.lang.String
       java.io.File
    - generates:
       java.lang.String


    -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: MoveFile
     
    -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
     
    -file <adams.core.io.PlaceholderFile> (property: file)
        The target file or directory.
        default: ${CWD}
     
    -input-is-target <boolean> (property: inputIsTarget)
        If true, then the input token will be used as target and the file parameter 
        as source.
        default: false
     
    -atomic-move <boolean> (property: atomicMove)
        If true, then an atomic move operation will be attempted (NB: not supported 
        by all operating systems).
        default: false
     
    -num-attempts <int> (property: numAttempts)
        The number of attempts for moving.
        default: 1
        minimum: 1
     
    -attempt-interval <int> (property: attemptInterval)
        The time in msec to wait before the next attempt.
        default: 1000
        minimum: 0
     
    -output-moved-file <boolean> (property: outputMovedFile)
        If true, then the moved file rather than the input file gets forwarded.
        default: false
     
    Version:
    $Revision$
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • m_InputIsTarget

        protected boolean m_InputIsTarget
        whether the input token is the target instead.
      • m_AtomicMove

        protected boolean m_AtomicMove
        whether to perform an atomic move.
      • 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_OutputMovedFile

        protected boolean m_OutputMovedFile
        whether to output the moved file rather than the input.
    • Constructor Detail

      • MoveFile

        public MoveFile()
    • Method Detail

      • setFile

        public void setFile​(PlaceholderFile value)
        Sets the target file.
        Parameters:
        value - the file
      • getFile

        public PlaceholderFile getFile()
        Returns the target file.
        Returns:
        the file
      • fileTipText

        public String fileTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setInputIsTarget

        public void setInputIsTarget​(boolean value)
        Sets whether the input is the actual target, not the file.
        Parameters:
        value - if true then the input will be used as target and the file as source
      • getInputIsTarget

        public boolean getInputIsTarget()
        Returns whether the input is the actual target, not the file.
        Returns:
        true if the input will be used as target and the file as source
      • inputIsTargetTipText

        public String inputIsTargetTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setAtomicMove

        public void setAtomicMove​(boolean value)
        Sets whether to attempt atomic move operation.
        Specified by:
        setAtomicMove in interface AtomicMoveSupporter
        Parameters:
        value - if true then attempt atomic move operation
      • getAtomicMove

        public boolean getAtomicMove()
        Returns whether to attempt atomic move operation.
        Specified by:
        getAtomicMove in interface AtomicMoveSupporter
        Returns:
        true if to attempt atomic move operation
      • atomicMoveTipText

        public String atomicMoveTipText()
        Returns the tip text for this property.
        Specified by:
        atomicMoveTipText in interface AtomicMoveSupporter
        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 interface MultiAttemptSupporter
        Parameters:
        value - the number of attempts
      • getNumAttempts

        public int getNumAttempts()
        Returns the number of attempts.
        Specified by:
        getNumAttempts in interface MultiAttemptSupporter
        Returns:
        the number of attempts
      • numAttemptsTipText

        public String numAttemptsTipText()
        Returns the tip text for this property.
        Specified by:
        numAttemptsTipText in interface MultiAttemptSupporter
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • attemptIntervalTipText

        public String attemptIntervalTipText()
        Returns the tip text for this property.
        Specified by:
        attemptIntervalTipText in interface MultiAttemptWithWaitSupporter
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setOutputMovedFile

        public void setOutputMovedFile​(boolean value)
        Sets whether to output the moved file rather than the input file.
        Parameters:
        value - if true then the moved file is output
      • getOutputMovedFile

        public boolean getOutputMovedFile()
        Returns whether to output the moved file rather than the input file.
        Returns:
        true if to output the moved file
      • outputMovedFileTipText

        public String outputMovedFileTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • accepts

        public Class[] accepts()
        Returns the class that the consumer accepts.
        Specified by:
        accepts in interface InputConsumer
        Returns:
        java.lang.String.class, java.io.File.class
      • generates

        public Class[] generates()
        Returns the class of objects that it generates.
        Specified by:
        generates in interface OutputProducer
        Returns:
        java.lang.String.class
      • doExecute

        protected String doExecute()
        Executes the flow item.
        Specified by:
        doExecute in class AbstractActor
        Returns:
        null if everything is fine, otherwise error message