Top Description Fields Constructors Methods
org.h2.store.fs

public abstract Class FileBaseDefault

extends FileBase
Class Inheritance
Known Direct Subclasses
org.h2.store.fs.async.FileAsync, org.h2.store.fs.encrypt.FileEncrypt, org.h2.store.fs.mem.FileMem, org.h2.store.fs.niomapped.FileNioMapped, org.h2.store.fs.niomem.FileNioMem, org.h2.store.fs.split.FileSplit
Imports
java.io.IOException, java.nio.ByteBuffer, java.nio.channels.FileChannel

Default implementation of the slow operations that need synchronization because they involve the file position.

Field Summary

Modifier and TypeField and Description
private long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected abstract void
implTruncate(long
the new size
size
)

The truncate implementation.

public final synchronized long
position()

Implements abstract java.nio.channels.FileChannel.position.

Implements java.nio.channels.SeekableByteChannel.position.

Returns this channel's file position.

public final synchronized FileChannel
position(long
The new position, a non-negative integer counting the number of bytes from the beginning of the file
newPosition
)

Implements abstract java.nio.channels.FileChannel.position.

Implements java.nio.channels.SeekableByteChannel.position.

Sets this channel's file position.

public final synchronized int
read(ByteBuffer
The buffer into which bytes are to be transferred
dst
)

Implements abstract java.nio.channels.FileChannel.read.

Implements java.nio.channels.SeekableByteChannel.read, java.nio.channels.ReadableByteChannel.read.

Reads a sequence of bytes from this channel into the given buffer.

public final synchronized FileChannel
truncate(long
The new size, a non-negative byte count
newLength
)

Implements abstract java.nio.channels.FileChannel.truncate.

Implements java.nio.channels.SeekableByteChannel.truncate.

Truncates this channel's file to the given size.

public final synchronized int
write(ByteBuffer
The buffer from which bytes are to be retrieved
src
)

Implements abstract java.nio.channels.FileChannel.write.

Implements java.nio.channels.SeekableByteChannel.write, java.nio.channels.WritableByteChannel.write.

Writes a sequence of bytes to this channel from the given buffer.

Inherited from org.h2.store.fs.FileBase:
forceimplCloseChannellockmapreadreadtransferFromtransferTotryLockwritewrite

Field Detail

positionback to summary
private long position

Constructor Detail

FileBaseDefaultback to summary
public FileBaseDefault()

Method Detail

implTruncateback to summary
protected abstract void implTruncate(long size) throws IOException

The truncate implementation.

Parameters
size:long

the new size

Exceptions
IOException:
on failure
positionback to summary
public final synchronized long position() throws IOException

Implements abstract java.nio.channels.FileChannel.position.

Implements java.nio.channels.SeekableByteChannel.position.

Doc from java.nio.channels.FileChannel.position.

Returns this channel's file position.

Returns:long

This channel's file position, a non-negative integer counting the number of bytes from the beginning of the file to the current position

Annotations
@Override
Exceptions
IOException:
If some other I/O error occurs
positionback to summary
public final synchronized FileChannel position(long newPosition) throws IOException

Implements abstract java.nio.channels.FileChannel.position.

Implements java.nio.channels.SeekableByteChannel.position.

Doc from java.nio.channels.FileChannel.position.

Sets this channel's file position.

Setting the position to a value that is greater than the file's current size is legal but does not change the size of the file. A later attempt to read bytes at such a position will immediately return an end-of-file indication. A later attempt to write bytes at such a position will cause the file to be grown to accommodate the new bytes; the values of any bytes between the previous end-of-file and the newly-written bytes are unspecified.

Parameters
newPosition:long

The new position, a non-negative integer counting the number of bytes from the beginning of the file

Returns:FileChannel

This file channel

Annotations
@Override
Exceptions
IOException:
If some other I/O error occurs
readback to summary
public final synchronized int read(ByteBuffer dst) throws IOException

Implements abstract java.nio.channels.FileChannel.read.

Implements java.nio.channels.SeekableByteChannel.read, java.nio.channels.ReadableByteChannel.read.

Doc from java.nio.channels.FileChannel.read.

Reads a sequence of bytes from this channel into the given buffer.

Bytes are read starting at this channel's current file position, and then the file position is updated with the number of bytes actually read. Otherwise this method behaves exactly as specified in the ReadableByteChannel interface.

Parameters
dst:ByteBuffer

Doc from java.nio.channels.ReadableByteChannel.read.

The buffer into which bytes are to be transferred

Returns:int

Doc from java.nio.channels.ReadableByteChannel.read.

The number of bytes read, possibly zero, or -1 if the channel has reached end-of-stream

Annotations
@Override
Exceptions
IOException:

Doc from java.nio.channels.ReadableByteChannel.read.

If some other I/O error occurs

truncateback to summary
public final synchronized FileChannel truncate(long newLength) throws IOException

Implements abstract java.nio.channels.FileChannel.truncate.

Implements java.nio.channels.SeekableByteChannel.truncate.

Doc from java.nio.channels.FileChannel.truncate.

Truncates this channel's file to the given size.

If the given size is less than the file's current size then the file is truncated, discarding any bytes beyond the new end of the file. If the given size is greater than or equal to the file's current size then the file is not modified. In either case, if this channel's file position is greater than the given size then it is set to that size.

Parameters
newLength:long

The new size, a non-negative byte count

Returns:FileChannel

This file channel

Annotations
@Override
Exceptions
IOException:
If some other I/O error occurs
writeback to summary
public final synchronized int write(ByteBuffer src) throws IOException

Implements abstract java.nio.channels.FileChannel.write.

Implements java.nio.channels.SeekableByteChannel.write, java.nio.channels.WritableByteChannel.write.

Doc from java.nio.channels.FileChannel.write.

Writes a sequence of bytes to this channel from the given buffer.

Bytes are written starting at this channel's current file position unless the channel is in append mode, in which case the position is first advanced to the end of the file. The file is grown, if necessary, to accommodate the written bytes, and then the file position is updated with the number of bytes actually written. Otherwise this method behaves exactly as specified by the WritableByteChannel interface.

Parameters
src:ByteBuffer

Doc from java.nio.channels.WritableByteChannel.write.

The buffer from which bytes are to be retrieved

Returns:int

Doc from java.nio.channels.WritableByteChannel.write.

The number of bytes written, possibly zero

Annotations
@Override
Exceptions
IOException:

Doc from java.nio.channels.WritableByteChannel.write.

If some other I/O error occurs