Top Description Inners Fields Constructors Methods
org.apache.sshd.sftp.client.fs

public Class SftpClientDirectoryScanner

extends PathScanningMatcher
Class Inheritance
Imports
java.io.IOException, java.util.ArrayList, .Arrays, .Collection, .Collections, .LinkedList, java.util.function.Supplier, java.util.stream.Collectors, org.apache.sshd.common.util.GenericUtils, .ValidateUtils, org.apache.sshd.common.util.io.PathScanningMatcher, org.apache.sshd.sftp.client.SftpClient, .SftpClient.Attributes, .SftpClient.DirEntry

Uses an SftpClient to scan a directory (possibly recursively) and find files that match a given set of inclusion patterns.
Author
Apache MINA SSHD Project

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
protected String
private boolean
Inherited from org.apache.sshd.common.util.io.PathScanningMatcher:
caseSensitiveincludePatternsseparator

Constructor Summary

AccessConstructor and Description
public
public
SftpClientDirectoryScanner(boolean caseSensitive)

public
public
public

Method Summary

Modifier and TypeMethod and Description
protected String
public String
public String
public boolean

Returns:

true if items that are not regular files or subdirectories shall be omitted; false otherwise
isFilesOnly
()

Tells whether the scanner is set to return only files and links (the default).

public Collection<SftpClientDirectoryScanner.ScanDirEntry>

Returns:

A Collection of ScanDirEntry-ies matching the inclusion patterns
scan
(SftpClient
The SftpClient instance to use
client
)

Scans the current basedir

public <C extends Collection<SftpClientDirectoryScanner.ScanDirEntry>> C
scan(SftpClient client, Supplier<? extends C> factory)

protected <
Generic collection type
C extends Collection<SftpClientDirectoryScanner.ScanDirEntry>
>
C

Returns:

The updated Collection of ScanDirEntry-ies
scandir
(SftpClient
The SftpClient instance to use
client
,
String
The absolute path of the folder to read
rootDir
,
String
The relative parent of the folder to read - may be empty for base directory
parent
,
C
The (never null) Collection of ScanDirEntry-ies to update
filesList
)

public void
setBasedir(String
The base directory from which to start scanning

Note

it is converted to its canonical form when scanning. May not be null/empty

basedir
)

public void
setFilesOnly(boolean
whether to skip all items that are not regular files, links, or subdirectories
filesOnly
)

Sets whether the scanner shall return only regular files, links, and subdirectories.

public void
public void
Inherited from org.apache.sshd.common.util.io.PathScanningMatcher:
couldHoldIncludedgetIncludesisCaseSensitiveisIncludednormalizePatternsetCaseSensitivesetIncludes

Field Detail

basedirback to summary
protected String basedir
filesOnlyback to summary
private boolean filesOnly

Constructor Detail

SftpClientDirectoryScannerback to summary
public SftpClientDirectoryScanner()
SftpClientDirectoryScannerback to summary
public SftpClientDirectoryScanner(boolean caseSensitive)
SftpClientDirectoryScannerback to summary
public SftpClientDirectoryScanner(String dir)
SftpClientDirectoryScannerback to summary
public SftpClientDirectoryScanner(String dir, String... includes)
SftpClientDirectoryScannerback to summary
public SftpClientDirectoryScanner(String dir, Collection<String> includes)

Method Detail

createRelativePathback to summary
protected String createRelativePath(String parent, String name)
getBasedirback to summary
public String getBasedir()
getSeparatorback to summary
public String getSeparator()

Overrides org.apache.sshd.common.util.io.PathScanningMatcher.getSeparator.

Returns:String

Doc from org.apache.sshd.common.util.io.PathScanningMatcher.getSeparator.

The file separator to use to parse paths - default=local O/S separator

Annotations
@Override
isFilesOnlyback to summary
public boolean isFilesOnly()

Tells whether the scanner is set to return only files and links (the default).

Returns:boolean

true if items that are not regular files or subdirectories shall be omitted; false otherwise

scanback to summary
public Collection<SftpClientDirectoryScanner.ScanDirEntry> scan(SftpClient client) throws IOException, IllegalStateException

Scans the current basedir

Parameters
client:SftpClient

The SftpClient instance to use

Returns:Collection<SftpClientDirectoryScanner.ScanDirEntry>

A Collection of ScanDirEntry-ies matching the inclusion patterns

Exceptions
IOException:
If failed to access the remote file system
IllegalStateException:
If illegal/missing base directory, or missing inclusion patterns, or specified base path is not a directory
scanback to summary
public <C extends Collection<SftpClientDirectoryScanner.ScanDirEntry>> C scan(SftpClient client, Supplier<? extends C> factory) throws IOException, IllegalStateException
scandirback to summary
protected <C extends Collection<SftpClientDirectoryScanner.ScanDirEntry>> C scandir(SftpClient client, String rootDir, String parent, C filesList) throws IOException
Parameters
<C>
Generic collection type
client:SftpClient

The SftpClient instance to use

rootDir:String

The absolute path of the folder to read

parent:String

The relative parent of the folder to read - may be empty for base directory

filesList:C

The (never null) Collection of ScanDirEntry-ies to update

Returns:C

The updated Collection of ScanDirEntry-ies

Exceptions
IOException:
If failed to access remote file system
setBasedirback to summary
public void setBasedir(String basedir)
Parameters
basedir:String

The base directory from which to start scanning

Note

it is converted to its canonical form when scanning. May not be null/empty

setFilesOnlyback to summary
public void setFilesOnly(boolean filesOnly)

Sets whether the scanner shall return only regular files, links, and subdirectories.

Parameters
filesOnly:boolean

whether to skip all items that are not regular files, links, or subdirectories

setIncludesback to summary
public void setIncludes(Collection<String> includes)

Overrides org.apache.sshd.common.util.io.PathScanningMatcher.setIncludes.

Annotations
@Override
setSeparatorback to summary
public void setSeparator(String separator)

Overrides org.apache.sshd.common.util.io.PathScanningMatcher.setSeparator.

Annotations
@Override
org.apache.sshd.sftp.client.fs back to summary

public Class SftpClientDirectoryScanner.ScanDirEntry

extends DirEntry
Class Inheritance

The result of a scan
Author
Apache MINA SSHD Project

Field Summary

Modifier and TypeField and Description
private final String
private final String
Inherited from org.apache.sshd.sftp.client.SftpClient.DirEntry:
BY_CASE_INSENSITIVE_FILENAMEBY_CASE_SENSITIVE_FILENAME

Constructor Summary

AccessConstructor and Description
public
ScanDirEntry(String fullPath, String relativePath, SftpClient.DirEntry dirEntry)

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

The full path represented by this entry
getFullPath
()

public String

Returns:

The relative path from the base directory used for scanning
getRelativePath
()

public String
toString()

Overrides org.apache.sshd.sftp.client.SftpClient.DirEntry.toString.

Returns a string representation of the object.

Inherited from org.apache.sshd.sftp.client.SftpClient.DirEntry:
getAttributesgetFilenamegetLongFilename

Field Detail

fullPathback to summary
private final String fullPath
relativePathback to summary
private final String relativePath

Constructor Detail

ScanDirEntryback to summary
public ScanDirEntry(String fullPath, String relativePath, SftpClient.DirEntry dirEntry)

Method Detail

getFullPathback to summary
public String getFullPath()
Returns:String

The full path represented by this entry

getRelativePathback to summary
public String getRelativePath()
Returns:String

The relative path from the base directory used for scanning

toStringback to summary
public String toString()

Overrides org.apache.sshd.sftp.client.SftpClient.DirEntry.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override