Class SftpDirEntryIterator
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.client.subsystem.sftp.SftpDirEntryIterator
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Channel
,Iterator<SftpClient.DirEntry>
public class SftpDirEntryIterator extends AbstractLoggingBean implements 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
Constructors Constructor Description SftpDirEntryIterator(SftpClient client, String path)
SftpDirEntryIterator(SftpClient client, String path, SftpClient.Handle dirHandle, boolean closeOnFinished)
SftpDirEntryIterator(SftpClient client, SftpClient.Handle dirHandle)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
SftpClient
getClient()
The client instanceSftpClient.Handle
getHandle()
String
getPath()
The remotely accessed directory pathboolean
hasNext()
boolean
isCloseOnFinished()
boolean
isOpen()
protected List<SftpClient.DirEntry>
load(SftpClient.Handle handle)
SftpClient.DirEntry
next()
void
remove()
-
Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
getSimplifiedLogger
-
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 Detail
-
SftpDirEntryIterator
public SftpDirEntryIterator(SftpClient client, String path) throws IOException
- 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
public SftpDirEntryIterator(SftpClient client, SftpClient.Handle dirHandle)
- 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 Detail
-
getClient
public final SftpClient getClient()
The client instance- Returns:
SftpClient
instance used to access the remote folder
-
getPath
public final String 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
public final SftpClient.Handle getHandle()
- Returns:
- The directory
SftpClient.Handle
used to access the remote directory
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfaceIterator<SftpClient.DirEntry>
-
next
public SftpClient.DirEntry next()
- Specified by:
next
in interfaceIterator<SftpClient.DirEntry>
-
isCloseOnFinished
public boolean isCloseOnFinished()
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceChannel
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
load
protected List<SftpClient.DirEntry> load(SftpClient.Handle handle)
-
remove
public void remove()
- Specified by:
remove
in interfaceIterator<SftpClient.DirEntry>
-
-