Class TestFileProcessor

  • All Implemented Interfaces:
    FileProcessor

    public class TestFileProcessor
    extends java.lang.Object
    implements FileProcessor
    A simple file processor implementation to help satisfy component requirements during tests.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void copy​(java.io.File source, java.io.File target)
      Copies the specified source file to the given target file.
      long copy​(java.io.File source, java.io.File target, FileProcessor.ProgressListener listener)
      Copies the specified source file to the given target file.
      private long copy​(java.io.OutputStream os, java.io.InputStream is, FileProcessor.ProgressListener listener)  
      boolean mkdirs​(java.io.File directory)
      Creates the directory named by the given abstract pathname, including any necessary but nonexistent parent directories.
      void move​(java.io.File source, java.io.File target)
      Moves the specified source file to the given target file.
      void write​(java.io.File target, java.io.InputStream source)
      Writes the given stream to a file.
      void write​(java.io.File file, java.lang.String data)
      Writes the given data to a file.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TestFileProcessor

        public TestFileProcessor()
    • Method Detail

      • mkdirs

        public boolean mkdirs​(java.io.File directory)
        Description copied from interface: FileProcessor
        Creates the directory named by the given abstract pathname, including any necessary but nonexistent parent directories. Note that if this operation fails it may have succeeded in creating some of the necessary parent directories.
        Specified by:
        mkdirs in interface FileProcessor
        Parameters:
        directory - The directory to create, may be null.
        Returns:
        true if and only if the directory was created, along with all necessary parent directories; false otherwise
      • write

        public void write​(java.io.File file,
                          java.lang.String data)
                   throws java.io.IOException
        Description copied from interface: FileProcessor
        Writes the given data to a file. UTF-8 is assumed as encoding for the data. Creates the necessary directories for the target file. In case of an error, the created directories will be left on the file system.
        Specified by:
        write in interface FileProcessor
        Parameters:
        file - The file to write to, must not be null. This file will be overwritten.
        data - The data to write, may be null.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • write

        public void write​(java.io.File target,
                          java.io.InputStream source)
                   throws java.io.IOException
        Description copied from interface: FileProcessor
        Writes the given stream to a file. Creates the necessary directories for the target file. In case of an error, the created directories will be left on the file system.
        Specified by:
        write in interface FileProcessor
        Parameters:
        target - The file to write to, must not be null. This file will be overwritten.
        source - The stream to write to the file, must not be null.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • copy

        public void copy​(java.io.File source,
                         java.io.File target)
                  throws java.io.IOException
        Description copied from interface: FileProcessor
        Copies the specified source file to the given target file. Creates the necessary directories for the target file. In case of an error, the created directories will be left on the file system.
        Specified by:
        copy in interface FileProcessor
        Parameters:
        source - The file to copy from, must not be null.
        target - The file to copy to, must not be null.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • copy

        public long copy​(java.io.File source,
                         java.io.File target,
                         FileProcessor.ProgressListener listener)
                  throws java.io.IOException
        Description copied from interface: FileProcessor
        Copies the specified source file to the given target file. Creates the necessary directories for the target file. In case of an error, the created directories will be left on the file system.
        Specified by:
        copy in interface FileProcessor
        Parameters:
        source - The file to copy from, must not be null.
        target - The file to copy to, must not be null.
        listener - The listener to notify about the copy progress, may be null.
        Returns:
        The number of copied bytes.
        Throws:
        java.io.IOException - If an I/O error occurs.
      • copy

        private long copy​(java.io.OutputStream os,
                          java.io.InputStream is,
                          FileProcessor.ProgressListener listener)
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • move

        public void move​(java.io.File source,
                         java.io.File target)
                  throws java.io.IOException
        Description copied from interface: FileProcessor
        Moves the specified source file to the given target file. If the target file already exists, it is overwritten. Creates the necessary directories for the target file. In case of an error, the created directories will be left on the file system.
        Specified by:
        move in interface FileProcessor
        Parameters:
        source - The file to move from, must not be null.
        target - The file to move to, must not be null.
        Throws:
        java.io.IOException - If an I/O error occurs.