com.giraone.io.copier.FileTreeProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of file-tree-copier Show documentation
Show all versions of file-tree-copier Show documentation
Utility JAR for copying a file tree from web server or from classpath resources to a (local) file system.
The newest version!
package com.giraone.io.copier;
import com.giraone.io.copier.model.FileTree;
import java.util.function.Function;
public interface FileTreeProvider {
/**
* Configure the file tree provider to traverse only directories matching a filter.
*
* @param sourceTraverseFilterFunction a filter function on the source file
* @return the called object
*/
FileTreeProvider withTraverseFilter(Function sourceTraverseFilterFunction);
/**
* Configure the file tree provider to return only files matching a filter,
* e.g. name matches a certain file extension.
*
* @param sourceFileFilterFunction a filter function on the source file
* @return the called object
*/
FileTreeProvider withFileFilter(Function sourceFileFilterFunction);
/**
* Traverse the defined source and return a node tree
*
* @return a file tree with directories (branches) and regular files (leafs)
*/
FileTree provideTree();
/**
* Derive the relative path of the file created within the target directory, when the
* source node is given. A typical example for HTTP would be
*
* ROOT URL = http://localhost:8080/subdir1
* fileTreeNode = http://localhost:8080/subdir1/subdir11/file.txt
* RESULT = subdir11/file.txt
*
* @param fileTreeNode the source node
* @return the relative path
*/
String calculateRelativeTargetFilePath(T fileTreeNode);
/**
* Return the implementation used to read from a URL. For file tree provided by a web server,
* this is typically an HTTP client implementation. For reading trees from other sources,
* e.g. file trees or class path trees, the default implementation
* {@link com.giraone.io.copier.resource.DirectReadFromUrlStreamProvider} can be used.
* @return the providing implementation
*/
ReadFromUrlStreamProvider getReadFromUrlInputStreamProvider();
}