Package org.apache.sshd.sftp.client.impl
Class SftpDirEntryIterator
java.lang.Object
org.apache.sshd.common.util.logging.AbstractLoggingBean
org.apache.sshd.sftp.client.impl.SftpDirEntryIterator
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Channel
,Iterator<SftpClient.DirEntry>
,SftpClientHolder
public class SftpDirEntryIterator
extends org.apache.sshd.common.util.logging.AbstractLoggingBean
implements SftpClientHolder, Iterator<SftpClient.DirEntry>, Channel
Iterates over the available directory entries for a given path. Note: if the iteration is carried out until no
more entries are available, then no need to close the iterator. Otherwise, it is recommended to close it so as to
release the internal handle.
- Author:
- Apache MINA SSHD Project
-
Field Summary
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
Constructor Summary
ConstructorsConstructorDescriptionSftpDirEntryIterator
(SftpClient client, String path) SftpDirEntryIterator
(SftpClient client, String path, SftpClient.Handle dirHandle, boolean closeOnFinished) SftpDirEntryIterator
(SftpClient client, SftpClient.Handle dirHandle) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
final SftpClient
final SftpClient.Handle
final String
getPath()
The remotely accessed directory pathboolean
hasNext()
boolean
boolean
isOpen()
protected List<SftpClient.DirEntry>
load
(SftpClient.Handle handle) next()
void
remove()
Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
SftpDirEntryIterator
- Parameters:
client
- TheSftpClient
instance to use for the iterationpath
- The remote directory path- Throws:
IOException
- If failed to gain access to the remote directory path
-
SftpDirEntryIterator
- Parameters:
client
- TheSftpClient
instance to use for the iterationdirHandle
- The directorySftpClient.Handle
to use for listing the entries
-
SftpDirEntryIterator
public SftpDirEntryIterator(SftpClient client, String path, SftpClient.Handle dirHandle, boolean closeOnFinished) - Parameters:
client
- TheSftpClient
instance to use for the iterationpath
- A hint as to the remote directory path - used only for loggingdirHandle
- The directorySftpClient.Handle
to use for listing the entriescloseOnFinished
- Iftrue
then close the directory handle when all entries have been exhausted
-
-
Method Details
-
getClient
- Specified by:
getClient
in interfaceSftpClientHolder
-
getPath
The remotely accessed directory path- Returns:
- Remote directory hint - may be the handle's value if accessed directly via a
SftpClient.Handle
instead of via a path - used only for logging
-
getHandle
- Returns:
- The directory
SftpClient.Handle
used to access the remote directory
-
hasNext
public boolean hasNext()- Specified by:
hasNext
in interfaceIterator<SftpClient.DirEntry>
-
next
- Specified by:
next
in interfaceIterator<SftpClient.DirEntry>
-
isOpen
public boolean isOpen() -
isCloseOnFinished
public boolean isCloseOnFinished() -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceChannel
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
load
-
remove
public void remove()- Specified by:
remove
in interfaceIterator<SftpClient.DirEntry>
-