Package org.apache.sshd.sftp.client.impl
Class SftpInputStreamAsync
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.sshd.common.util.io.input.InputStreamWithChannel
-
- org.apache.sshd.sftp.client.impl.SftpInputStreamAsync
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.nio.channels.Channel,SftpClientHolder
public class SftpInputStreamAsync extends InputStreamWithChannel implements SftpClientHolder
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static interfaceSftpInputStreamAsync.BufferConsumer
-
Field Summary
Fields Modifier and Type Field Description protected byte[]bbprotected Bufferbufferprotected intbufferSizeprivate AbstractSftpClientclientInstanceprotected longclientOffsetprotected booleaneofIndicatorprotected longfileSizeprotected SftpClient.CloseableHandlehandleprotected org.slf4j.Loggerlogprivate java.lang.Stringpathprotected java.util.Deque<SftpAckData>pendingReadsprotected longrequestOffset
-
Constructor Summary
Constructors Constructor Description SftpInputStreamAsync(AbstractSftpClient client, int bufferSize, long clientOffset, long fileSize, java.lang.String path, SftpClient.CloseableHandle handle)SftpInputStreamAsync(AbstractSftpClient client, int bufferSize, java.lang.String path, java.util.Collection<SftpClient.OpenMode> mode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()private longdoRead(long max, SftpInputStreamAsync.BufferConsumer consumer)protected voidfillData()AbstractSftpClientgetClient()java.lang.StringgetPath()The remotely accessed file pathprotected booleanhasNoData()booleanisEof()Check if the stream is at EOFbooleanisOpen()protected voidpollBuffer(SftpAckData ack)intread()intread(byte[] b, int off, int len)protected voidsendRequests()longskip(long n)java.lang.StringtoString()longtransferTo(long len, java.nio.channels.WritableByteChannel out)longtransferTo(java.io.OutputStream out)
-
-
-
Field Detail
-
log
protected final org.slf4j.Logger log
-
bb
protected final byte[] bb
-
bufferSize
protected final int bufferSize
-
fileSize
protected final long fileSize
-
buffer
protected Buffer buffer
-
handle
protected SftpClient.CloseableHandle handle
-
requestOffset
protected long requestOffset
-
clientOffset
protected long clientOffset
-
pendingReads
protected final java.util.Deque<SftpAckData> pendingReads
-
eofIndicator
protected boolean eofIndicator
-
clientInstance
private final AbstractSftpClient clientInstance
-
path
private final java.lang.String path
-
-
Constructor Detail
-
SftpInputStreamAsync
public SftpInputStreamAsync(AbstractSftpClient client, int bufferSize, java.lang.String path, java.util.Collection<SftpClient.OpenMode> mode) throws java.io.IOException
- Throws:
java.io.IOException
-
SftpInputStreamAsync
public SftpInputStreamAsync(AbstractSftpClient client, int bufferSize, long clientOffset, long fileSize, java.lang.String path, SftpClient.CloseableHandle handle)
-
-
Method Detail
-
getClient
public final AbstractSftpClient getClient()
- Specified by:
getClientin interfaceSftpClientHolder
-
getPath
public final java.lang.String getPath()
The remotely accessed file path- Returns:
- Remote file path
-
isEof
public boolean isEof()
Check if the stream is at EOF- Returns:
trueif all the data has been consumer
-
isOpen
public boolean isOpen()
- Specified by:
isOpenin interfacejava.nio.channels.Channel
-
read
public int read() throws java.io.IOException- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
transferTo
public long transferTo(long len, java.nio.channels.WritableByteChannel out) throws java.io.IOException- Throws:
java.io.IOException
-
transferTo
public long transferTo(java.io.OutputStream out) throws java.io.IOException- Overrides:
transferToin classjava.io.InputStream- Throws:
java.io.IOException
-
doRead
private long doRead(long max, SftpInputStreamAsync.BufferConsumer consumer) throws java.io.IOException- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOException- Overrides:
skipin classjava.io.InputStream- Throws:
java.io.IOException
-
hasNoData
protected boolean hasNoData()
-
sendRequests
protected void sendRequests() throws java.io.IOException- Throws:
java.io.IOException
-
fillData
protected void fillData() throws java.io.IOException- Throws:
java.io.IOException
-
pollBuffer
protected void pollBuffer(SftpAckData ack) throws java.io.IOException
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.nio.channels.Channel- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-