public class SftpRemotePathChannel
extends java.nio.channels.FileChannel
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.atomic.AtomicReference<java.lang.Thread> |
blockingThreadHolder |
private boolean |
closeOnExit |
static java.lang.String |
COPY_BUFSIZE_PROP |
static int |
DEFAULT_TRANSFER_BUFFER_SIZE |
private SftpClient.CloseableHandle |
handle |
private java.lang.Object |
lock |
private java.util.Collection<SftpClient.OpenMode> |
modes |
private java.lang.String |
path |
private java.util.concurrent.atomic.AtomicLong |
posTracker |
static java.util.Set<SftpClient.OpenMode> |
READ_MODES |
private SftpClient |
sftp |
static java.util.Set<SftpClient.OpenMode> |
WRITE_MODES |
Constructor and Description |
---|
SftpRemotePathChannel(java.lang.String path,
SftpClient sftp,
boolean closeOnExit,
java.util.Collection<SftpClient.OpenMode> modes) |
Modifier and Type | Method and Description |
---|---|
private void |
beginBlocking() |
protected long |
doRead(java.util.List<java.nio.ByteBuffer> buffers,
long position) |
protected long |
doWrite(java.util.List<java.nio.ByteBuffer> buffers,
long position) |
private void |
endBlocking(boolean completed) |
private void |
ensureOpen(java.util.Collection<SftpClient.OpenMode> reqModes)
Checks that the channel is open and that its current mode contains
at least one of the required ones
|
void |
force(boolean metaData) |
java.lang.String |
getRemotePath() |
protected void |
implCloseChannel() |
java.nio.channels.FileLock |
lock(long position,
long size,
boolean shared) |
java.nio.MappedByteBuffer |
map(java.nio.channels.FileChannel.MapMode mode,
long position,
long size) |
long |
position() |
java.nio.channels.FileChannel |
position(long newPosition) |
int |
read(java.nio.ByteBuffer dst) |
long |
read(java.nio.ByteBuffer[] dsts,
int offset,
int length) |
int |
read(java.nio.ByteBuffer dst,
long position) |
long |
size() |
java.lang.String |
toString() |
long |
transferFrom(java.nio.channels.ReadableByteChannel src,
long position,
long count) |
long |
transferTo(long position,
long count,
java.nio.channels.WritableByteChannel target) |
java.nio.channels.FileChannel |
truncate(long size) |
java.nio.channels.FileLock |
tryLock(long position,
long size,
boolean shared) |
int |
write(java.nio.ByteBuffer src) |
long |
write(java.nio.ByteBuffer[] srcs,
int offset,
int length) |
int |
write(java.nio.ByteBuffer src,
long position) |
begin, close, end, isOpen
public static final java.lang.String COPY_BUFSIZE_PROP
public static final int DEFAULT_TRANSFER_BUFFER_SIZE
public static final java.util.Set<SftpClient.OpenMode> READ_MODES
public static final java.util.Set<SftpClient.OpenMode> WRITE_MODES
private final java.lang.String path
private final java.util.Collection<SftpClient.OpenMode> modes
private final boolean closeOnExit
private final SftpClient sftp
private final SftpClient.CloseableHandle handle
private final java.lang.Object lock
private final java.util.concurrent.atomic.AtomicLong posTracker
private final java.util.concurrent.atomic.AtomicReference<java.lang.Thread> blockingThreadHolder
public SftpRemotePathChannel(java.lang.String path, SftpClient sftp, boolean closeOnExit, java.util.Collection<SftpClient.OpenMode> modes) throws java.io.IOException
java.io.IOException
public java.lang.String getRemotePath()
public int read(java.nio.ByteBuffer dst) throws java.io.IOException
read
in interface java.nio.channels.ReadableByteChannel
read
in interface java.nio.channels.SeekableByteChannel
read
in class java.nio.channels.FileChannel
java.io.IOException
public int read(java.nio.ByteBuffer dst, long position) throws java.io.IOException
read
in class java.nio.channels.FileChannel
java.io.IOException
public long read(java.nio.ByteBuffer[] dsts, int offset, int length) throws java.io.IOException
read
in interface java.nio.channels.ScatteringByteChannel
read
in class java.nio.channels.FileChannel
java.io.IOException
protected long doRead(java.util.List<java.nio.ByteBuffer> buffers, long position) throws java.io.IOException
java.io.IOException
public int write(java.nio.ByteBuffer src) throws java.io.IOException
write
in interface java.nio.channels.SeekableByteChannel
write
in interface java.nio.channels.WritableByteChannel
write
in class java.nio.channels.FileChannel
java.io.IOException
public int write(java.nio.ByteBuffer src, long position) throws java.io.IOException
write
in class java.nio.channels.FileChannel
java.io.IOException
public long write(java.nio.ByteBuffer[] srcs, int offset, int length) throws java.io.IOException
write
in interface java.nio.channels.GatheringByteChannel
write
in class java.nio.channels.FileChannel
java.io.IOException
protected long doWrite(java.util.List<java.nio.ByteBuffer> buffers, long position) throws java.io.IOException
java.io.IOException
public long position() throws java.io.IOException
position
in interface java.nio.channels.SeekableByteChannel
position
in class java.nio.channels.FileChannel
java.io.IOException
public java.nio.channels.FileChannel position(long newPosition) throws java.io.IOException
position
in interface java.nio.channels.SeekableByteChannel
position
in class java.nio.channels.FileChannel
java.io.IOException
public long size() throws java.io.IOException
size
in interface java.nio.channels.SeekableByteChannel
size
in class java.nio.channels.FileChannel
java.io.IOException
public java.nio.channels.FileChannel truncate(long size) throws java.io.IOException
truncate
in interface java.nio.channels.SeekableByteChannel
truncate
in class java.nio.channels.FileChannel
java.io.IOException
public void force(boolean metaData) throws java.io.IOException
force
in class java.nio.channels.FileChannel
java.io.IOException
public long transferTo(long position, long count, java.nio.channels.WritableByteChannel target) throws java.io.IOException
transferTo
in class java.nio.channels.FileChannel
java.io.IOException
public long transferFrom(java.nio.channels.ReadableByteChannel src, long position, long count) throws java.io.IOException
transferFrom
in class java.nio.channels.FileChannel
java.io.IOException
public java.nio.MappedByteBuffer map(java.nio.channels.FileChannel.MapMode mode, long position, long size) throws java.io.IOException
map
in class java.nio.channels.FileChannel
java.io.IOException
public java.nio.channels.FileLock lock(long position, long size, boolean shared) throws java.io.IOException
lock
in class java.nio.channels.FileChannel
java.io.IOException
public java.nio.channels.FileLock tryLock(long position, long size, boolean shared) throws java.io.IOException
tryLock
in class java.nio.channels.FileChannel
java.io.IOException
protected void implCloseChannel() throws java.io.IOException
implCloseChannel
in class java.nio.channels.spi.AbstractInterruptibleChannel
java.io.IOException
private void beginBlocking()
private void endBlocking(boolean completed) throws java.nio.channels.AsynchronousCloseException
java.nio.channels.AsynchronousCloseException
private void ensureOpen(java.util.Collection<SftpClient.OpenMode> reqModes) throws java.io.IOException
reqModes
- The required modes - ignored if null
/emptyjava.io.IOException
- If channel not open or the required modes are not
satisfiedpublic java.lang.String toString()
toString
in class java.lang.Object