Package org.cryptomator.cryptofs.ch
Class AbstractFileChannel
- java.lang.Object
-
- java.nio.channels.spi.AbstractInterruptibleChannel
-
- java.nio.channels.FileChannel
-
- org.cryptomator.cryptofs.ch.AbstractFileChannel
-
- All Implemented Interfaces:
Closeable,AutoCloseable,ByteChannel,Channel,GatheringByteChannel,InterruptibleChannel,ReadableByteChannel,ScatteringByteChannel,SeekableByteChannel,WritableByteChannel
- Direct Known Subclasses:
CleartextFileChannel
public abstract class AbstractFileChannel extends FileChannel
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.nio.channels.FileChannel
FileChannel.MapMode
-
-
Field Summary
Fields Modifier and Type Field Description protected longposition
-
Constructor Summary
Constructors Constructor Description AbstractFileChannel(ReadWriteLock readWriteLock)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidassertOpen()protected voidassertReadable()protected voidassertWritable()protected booleanbeginBlocking()Begins a blocking operation, making the operation interruptible.protected voidendBlocking(boolean completed)Ends a blocking operation, throwing an exception if the thread was interrupted while blocking or if the channel was closed from another thread.protected voidimplCloseChannel()protected abstract booleanisReadable()protected abstract booleanisWritable()longposition()FileChannelposition(long newPosition)intread(ByteBuffer dst)longread(ByteBuffer[] dsts, int offset, int length)intread(ByteBuffer dst, long position)protected abstract intreadLocked(ByteBuffer dst, long position)longtransferFrom(ReadableByteChannel src, long position, long count)protected longtransferFromLocked(ReadableByteChannel src, long position, long count)longtransferTo(long position, long count, WritableByteChannel target)protected longtransferToLocked(long position, long count, WritableByteChannel target)FileChanneltruncate(long size)protected abstract voidtruncateLocked(long size)intwrite(ByteBuffer src)longwrite(ByteBuffer[] srcs, int offset, int length)intwrite(ByteBuffer src, long position)protected abstract intwriteLocked(ByteBuffer src, long position)-
Methods inherited from class java.nio.channels.FileChannel
force, lock, lock, map, open, open, read, size, tryLock, tryLock, write
-
Methods inherited from class java.nio.channels.spi.AbstractInterruptibleChannel
begin, close, end, isOpen
-
-
-
-
Constructor Detail
-
AbstractFileChannel
public AbstractFileChannel(ReadWriteLock readWriteLock)
-
-
Method Detail
-
beginBlocking
protected boolean beginBlocking()
Begins a blocking operation, making the operation interruptible. Returnstrueif the channel was open and the thread was added as a blocking thread; returnsfalseif the channel was closed.
-
endBlocking
protected void endBlocking(boolean completed) throws AsynchronousCloseExceptionEnds a blocking operation, throwing an exception if the thread was interrupted while blocking or if the channel was closed from another thread.- Throws:
AsynchronousCloseException
-
implCloseChannel
protected void implCloseChannel() throws IOException- Specified by:
implCloseChannelin classAbstractInterruptibleChannel- Throws:
IOException
-
position
public long position() throws IOException- Specified by:
positionin interfaceSeekableByteChannel- Specified by:
positionin classFileChannel- Throws:
IOException
-
position
public FileChannel position(long newPosition) throws IOException
- Specified by:
positionin interfaceSeekableByteChannel- Specified by:
positionin classFileChannel- Throws:
IOException
-
assertWritable
protected void assertWritable() throws IOException- Throws:
IOException
-
isWritable
protected abstract boolean isWritable()
-
assertReadable
protected void assertReadable() throws IOException- Throws:
IOException
-
isReadable
protected abstract boolean isReadable()
-
assertOpen
protected void assertOpen() throws ClosedChannelException- Throws:
ClosedChannelException
-
read
public long read(ByteBuffer[] dsts, int offset, int length) throws IOException
- Specified by:
readin interfaceScatteringByteChannel- Specified by:
readin classFileChannel- Throws:
IOException
-
read
public int read(ByteBuffer dst) throws IOException
- Specified by:
readin interfaceReadableByteChannel- Specified by:
readin interfaceSeekableByteChannel- Specified by:
readin classFileChannel- Throws:
IOException
-
read
public int read(ByteBuffer dst, long position) throws IOException
- Specified by:
readin classFileChannel- Throws:
IOException
-
readLocked
protected abstract int readLocked(ByteBuffer dst, long position) throws IOException
- Throws:
IOException- See Also:
read(ByteBuffer, long)
-
write
public long write(ByteBuffer[] srcs, int offset, int length) throws IOException
- Specified by:
writein interfaceGatheringByteChannel- Specified by:
writein classFileChannel- Throws:
IOException
-
write
public int write(ByteBuffer src) throws IOException
- Specified by:
writein interfaceSeekableByteChannel- Specified by:
writein interfaceWritableByteChannel- Specified by:
writein classFileChannel- Throws:
IOException
-
write
public int write(ByteBuffer src, long position) throws IOException
- Specified by:
writein classFileChannel- Throws:
IOException
-
writeLocked
protected abstract int writeLocked(ByteBuffer src, long position) throws IOException
- Throws:
IOException- See Also:
write(ByteBuffer, long)
-
truncate
public FileChannel truncate(long size) throws IOException
- Specified by:
truncatein interfaceSeekableByteChannel- Specified by:
truncatein classFileChannel- Throws:
IOException
-
truncateLocked
protected abstract void truncateLocked(long size) throws IOException- Throws:
IOException- See Also:
truncate(long)
-
transferTo
public long transferTo(long position, long count, WritableByteChannel target) throws IOException- Specified by:
transferToin classFileChannel- Throws:
IOException
-
transferToLocked
protected long transferToLocked(long position, long count, WritableByteChannel target) throws IOException- Throws:
IOException
-
transferFrom
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException
- Specified by:
transferFromin classFileChannel- Throws:
IOException
-
transferFromLocked
protected long transferFromLocked(ReadableByteChannel src, long position, long count) throws IOException
- Throws:
IOException
-
-