Package com.marklogic.client.ext.file
Class DefaultDocumentFileReader
- java.lang.Object
-
- com.marklogic.client.ext.helper.LoggingObject
-
- com.marklogic.client.ext.file.AbstractDocumentFileReader
-
- com.marklogic.client.ext.file.DefaultDocumentFileReader
-
- All Implemented Interfaces:
DocumentFileReader,java.nio.file.FileVisitor<java.nio.file.Path>
public class DefaultDocumentFileReader extends AbstractDocumentFileReader implements java.nio.file.FileVisitor<java.nio.file.Path>, DocumentFileReader
Non-threadsafe implementation that implements FileVisitor as a way of descending one or more file paths.
-
-
Field Summary
-
Fields inherited from class com.marklogic.client.ext.helper.LoggingObject
logger
-
-
Constructor Summary
Constructors Constructor Description DefaultDocumentFileReader()Calls initialize to instantiate some default DocumentFileProcessor objects.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanacceptPath(java.nio.file.Path path, java.nio.file.attribute.BasicFileAttributes attrs)voidaddFileFilter(java.io.FileFilter fileFilter)protected DocumentFilebuildDocumentFile(java.nio.file.Path path, java.nio.file.Path currentRootPath)protected java.nio.file.PathconstructPath(java.lang.String path)The path is first wrapped in a File; this prevents a bug in Gradle when Gradle is run in daemon mode, where it will try to resolve the path from its daemon directory.CollectionsFileDocumentFileProcessorgetCollectionsFileDocumentFileProcessor()java.util.List<java.io.FileFilter>getFileFilters()PermissionsFileDocumentFileProcessorgetPermissionsFileDocumentFileProcessor()protected voidinitialize()java.nio.file.FileVisitResultpostVisitDirectory(java.nio.file.Path dir, java.io.IOException exc)java.nio.file.FileVisitResultpreVisitDirectory(java.nio.file.Path dir, java.nio.file.attribute.BasicFileAttributes attrs)java.util.List<DocumentFile>readDocumentFiles(java.lang.String... paths)Walk the file tree at each of the given paths, applying any configured DocumentFileProcessor instances on each DocumentFile that is constructed by a File.voidsetFileFilters(java.util.List<java.io.FileFilter> fileFilters)voidsetUriPrefix(java.lang.String uriPrefix)java.nio.file.FileVisitResultvisitFile(java.nio.file.Path path, java.nio.file.attribute.BasicFileAttributes attrs)java.nio.file.FileVisitResultvisitFileFailed(java.nio.file.Path file, java.io.IOException exc)-
Methods inherited from class com.marklogic.client.ext.file.AbstractDocumentFileReader
addDocumentFileProcessor, getDocumentFileProcessor, getDocumentFileProcessors, getFormatDocumentFileProcessor, isCatchProcessingError, processDocumentFile, setCatchProcessingError, setDocumentFileProcessors, setFormatDocumentFileProcessor
-
Methods inherited from class com.marklogic.client.ext.helper.LoggingObject
format
-
-
-
-
Method Detail
-
readDocumentFiles
public java.util.List<DocumentFile> readDocumentFiles(java.lang.String... paths)
Walk the file tree at each of the given paths, applying any configured DocumentFileProcessor instances on each DocumentFile that is constructed by a File.- Specified by:
readDocumentFilesin interfaceDocumentFileReader- Parameters:
paths-- Returns:
- list of DocumentFile objects in the given paths
-
constructPath
protected java.nio.file.Path constructPath(java.lang.String path)
The path is first wrapped in a File; this prevents a bug in Gradle when Gradle is run in daemon mode, where it will try to resolve the path from its daemon directory.- Parameters:
path-- Returns:
- a Path object based on the given string path
-
preVisitDirectory
public java.nio.file.FileVisitResult preVisitDirectory(java.nio.file.Path dir, java.nio.file.attribute.BasicFileAttributes attrs) throws java.io.IOException- Specified by:
preVisitDirectoryin interfacejava.nio.file.FileVisitor<java.nio.file.Path>- Throws:
java.io.IOException
-
visitFileFailed
public java.nio.file.FileVisitResult visitFileFailed(java.nio.file.Path file, java.io.IOException exc) throws java.io.IOException- Specified by:
visitFileFailedin interfacejava.nio.file.FileVisitor<java.nio.file.Path>- Throws:
java.io.IOException
-
postVisitDirectory
public java.nio.file.FileVisitResult postVisitDirectory(java.nio.file.Path dir, java.io.IOException exc) throws java.io.IOException- Specified by:
postVisitDirectoryin interfacejava.nio.file.FileVisitor<java.nio.file.Path>- Throws:
java.io.IOException
-
visitFile
public java.nio.file.FileVisitResult visitFile(java.nio.file.Path path, java.nio.file.attribute.BasicFileAttributes attrs) throws java.io.IOException- Specified by:
visitFilein interfacejava.nio.file.FileVisitor<java.nio.file.Path>- Throws:
java.io.IOException
-
acceptPath
protected boolean acceptPath(java.nio.file.Path path, java.nio.file.attribute.BasicFileAttributes attrs)- Parameters:
path-attrs-- Returns:
- false if any of the configured FileFilter objects do not accept the Path, else true
-
buildDocumentFile
protected DocumentFile buildDocumentFile(java.nio.file.Path path, java.nio.file.Path currentRootPath)
-
initialize
protected void initialize()
-
addFileFilter
public void addFileFilter(java.io.FileFilter fileFilter)
-
getFileFilters
public java.util.List<java.io.FileFilter> getFileFilters()
-
setFileFilters
public void setFileFilters(java.util.List<java.io.FileFilter> fileFilters)
-
setUriPrefix
public void setUriPrefix(java.lang.String uriPrefix)
-
getCollectionsFileDocumentFileProcessor
public CollectionsFileDocumentFileProcessor getCollectionsFileDocumentFileProcessor()
-
getPermissionsFileDocumentFileProcessor
public PermissionsFileDocumentFileProcessor getPermissionsFileDocumentFileProcessor()
-
-