Class TestFileProcessor
java.lang.Object
org.eclipse.aether.internal.test.util.TestFileProcessor
- All Implemented Interfaces:
FileProcessor
A simple file processor implementation to help satisfy component requirements during tests.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.aether.spi.io.FileProcessor
FileProcessor.ProgressListener
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Copies the specified source file to the given target file.long
copy
(File source, File target, FileProcessor.ProgressListener listener) Copies the specified source file to the given target file.private long
copy
(OutputStream os, InputStream is, FileProcessor.ProgressListener listener) boolean
Creates the directory named by the given abstract pathname, including any necessary but nonexistent parent directories.void
Moves the specified source file to the given target file.void
write
(File target, InputStream source) Writes the given stream to a file.void
Writes the given data to a file.
-
Constructor Details
-
TestFileProcessor
public TestFileProcessor()
-
-
Method Details
-
mkdirs
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 interfaceFileProcessor
- Parameters:
directory
- The directory to create, may benull
.- Returns:
true
if and only if the directory was created, along with all necessary parent directories;false
otherwise
-
write
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 interfaceFileProcessor
- Parameters:
file
- The file to write to, must not benull
. This file will be overwritten.data
- The data to write, may benull
.- Throws:
IOException
- If an I/O error occurs.
-
write
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 interfaceFileProcessor
- Parameters:
target
- The file to write to, must not benull
. This file will be overwritten.source
- The stream to write to the file, must not benull
.- Throws:
IOException
- If an I/O error occurs.
-
copy
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 interfaceFileProcessor
- Parameters:
source
- The file to copy from, must not benull
.target
- The file to copy to, must not benull
.- Throws:
IOException
- If an I/O error occurs.
-
copy
public long copy(File source, File target, FileProcessor.ProgressListener listener) throws 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 interfaceFileProcessor
- Parameters:
source
- The file to copy from, must not benull
.target
- The file to copy to, must not benull
.listener
- The listener to notify about the copy progress, may benull
.- Returns:
- The number of copied bytes.
- Throws:
IOException
- If an I/O error occurs.
-
copy
private long copy(OutputStream os, InputStream is, FileProcessor.ProgressListener listener) throws IOException - Throws:
IOException
-
move
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 interfaceFileProcessor
- Parameters:
source
- The file to move from, must not benull
.target
- The file to move to, must not benull
.- Throws:
IOException
- If an I/O error occurs.
-