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 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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final SftpClientprivate final booleanprivate List<SftpClient.DirEntry> private SftpClient.Handleprivate final Stringprivate final AtomicReference<Boolean> private intprivate final AtomicBooleanFields 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 TypeMethodDescriptionvoidclose()final SftpClientfinal SftpClient.Handlefinal StringgetPath()The remotely accessed directory pathbooleanhasNext()booleanbooleanisOpen()protected List<SftpClient.DirEntry> load(SftpClient.Handle handle) next()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, warnMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
eolIndicator
-
open
-
client
-
dirPath
-
closeOnFinished
private final boolean closeOnFinished -
dirHandle
-
dirEntries
-
index
private int index
-
-
Constructor Details
-
SftpDirEntryIterator
- 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
- 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 Details
-
getClient
- Specified by:
getClientin interfaceSftpClientHolder
-
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
- Returns:
- The directory
SftpClient.Handleused to access the remote directory
-
hasNext
public boolean hasNext()- Specified by:
hasNextin interfaceIterator<SftpClient.DirEntry>
-
next
- Specified by:
nextin interfaceIterator<SftpClient.DirEntry>
-
isOpen
public boolean isOpen() -
isCloseOnFinished
public boolean isCloseOnFinished() -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfaceCloseable- Throws:
IOException
-
load
-
remove
public void remove()- Specified by:
removein interfaceIterator<SftpClient.DirEntry>
-