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
-
-
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 voidclose()SftpClientgetClient()SftpClient.HandlegetHandle()StringgetPath()The remotely accessed directory pathbooleanhasNext()booleanisCloseOnFinished()booleanisOpen()protected List<SftpClient.DirEntry>load(SftpClient.Handle handle)SftpClient.DirEntrynext()voidremove()-
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 Detail
-
SftpDirEntryIterator
public SftpDirEntryIterator(SftpClient client, String path) throws IOException
- Parameters:
client- TheSftpClientinstance 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- TheSftpClientinstance to use for the iterationdirHandle- The directorySftpClient.Handleto use for listing the entries
-
SftpDirEntryIterator
public SftpDirEntryIterator(SftpClient client, String path, SftpClient.Handle dirHandle, boolean closeOnFinished)
- Parameters:
client- TheSftpClientinstance to use for the iterationpath- A hint as to the remote directory path - used only for loggingdirHandle- The directorySftpClient.Handleto use for listing the entriescloseOnFinished- Iftruethen close the directory handle when all entries have been exhausted
-
-
Method Detail
-
getClient
public final SftpClient getClient()
- Specified by:
getClientin interfaceSftpClientHolder
-
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.Handleinstead of via a path - used only for logging
-
getHandle
public final SftpClient.Handle getHandle()
- Returns:
- The directory
SftpClient.Handleused to access the remote directory
-
hasNext
public boolean hasNext()
- Specified by:
hasNextin interfaceIterator<SftpClient.DirEntry>
-
next
public SftpClient.DirEntry next()
- Specified by:
nextin interfaceIterator<SftpClient.DirEntry>
-
isCloseOnFinished
public boolean isCloseOnFinished()
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfaceCloseable- Throws:
IOException
-
load
protected List<SftpClient.DirEntry> load(SftpClient.Handle handle)
-
remove
public void remove()
- Specified by:
removein interfaceIterator<SftpClient.DirEntry>
-
-