|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.nio.channels.spi.AbstractInterruptibleChannel java.nio.channels.FileChannel com.healthmarketscience.jackcess.MemFileChannel
public class MemFileChannel
FileChannel implementation which maintains the entire "file" in memory.
This enables working with a Database entirely in memory (for situations
where disk usage may not be possible or desirable). Obviously, this
requires enough jvm heap space to fit the file data. Use one of the
newChannel()
methods to construct an instance of this class.
DatabaseBuilder
to open/create the Database instance, passing an instance
of this class to the DatabaseBuilder.setChannel(java.nio.channels.FileChannel)
method.
Implementation note: this class is optimized for use with Database
.
Therefore not all methods may be implemented and individual read/write
operations are only supported within page boundaries.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.nio.channels.FileChannel |
---|
FileChannel.MapMode |
Method Summary | |
---|---|
void |
force(boolean metaData)
|
FileLock |
lock(long position,
long size,
boolean shared)
|
MappedByteBuffer |
map(FileChannel.MapMode mode,
long position,
long size)
|
static MemFileChannel |
newChannel()
Creates a new read/write, empty MemFileChannel. |
static MemFileChannel |
newChannel(File file)
Creates a new read/write MemFileChannel containing the contents of the given File. |
static MemFileChannel |
newChannel(File file,
String mode)
Creates a new MemFileChannel containing the contents of the given File with the given mode (for mode details see RandomAccessFile.RandomAccessFile(File,String) ). |
static MemFileChannel |
newChannel(InputStream in)
Creates a new read/write MemFileChannel containing the contents of the given InputStream. |
static MemFileChannel |
newChannel(InputStream in,
String mode)
Creates a new MemFileChannel containing the contents of the given InputStream with the given mode (for mode details see RandomAccessFile.RandomAccessFile(File,String) ). |
static MemFileChannel |
newChannel(ReadableByteChannel in)
Creates a new read/write MemFileChannel containing the contents of the given ReadableByteChannel. |
static MemFileChannel |
newChannel(ReadableByteChannel in,
String mode)
Creates a new MemFileChannel containing the contents of the given ReadableByteChannel with the given mode (for mode details see RandomAccessFile.RandomAccessFile(File,String) ). |
long |
position()
|
FileChannel |
position(long newPosition)
|
int |
read(ByteBuffer dst)
|
long |
read(ByteBuffer[] dsts,
int offset,
int length)
|
int |
read(ByteBuffer dst,
long position)
|
long |
size()
|
long |
transferFrom(ReadableByteChannel src,
long position,
long count)
|
long |
transferTo(long position,
long count,
OutputStream dst)
Convenience method for writing the selected portion of this channel to the given destination stream. |
long |
transferTo(long position,
long count,
WritableByteChannel dst)
|
long |
transferTo(OutputStream dst)
Convenience method for writing the entire contents of this channel to the given destination stream. |
long |
transferTo(WritableByteChannel dst)
Convenience method for writing the entire contents of this channel to the given destination channel. |
FileChannel |
truncate(long newSize)
|
FileLock |
tryLock(long position,
long size,
boolean shared)
|
int |
write(ByteBuffer src)
|
long |
write(ByteBuffer[] srcs,
int offset,
int length)
|
int |
write(ByteBuffer src,
long position)
|
Methods inherited from class java.nio.channels.FileChannel |
---|
lock, read, tryLock, write |
Methods inherited from class java.nio.channels.spi.AbstractInterruptibleChannel |
---|
close, isOpen |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.nio.channels.Channel |
---|
close, isOpen |
Method Detail |
---|
public static MemFileChannel newChannel()
public static MemFileChannel newChannel(File file) throws IOException
IOException
public static MemFileChannel newChannel(File file, String mode) throws IOException
RandomAccessFile.RandomAccessFile(File,String)
). Note,
modifications to the returned channel will not affect the original
File source.
IOException
public static MemFileChannel newChannel(InputStream in) throws IOException
IOException
public static MemFileChannel newChannel(InputStream in, String mode) throws IOException
RandomAccessFile.RandomAccessFile(File,String)
).
IOException
public static MemFileChannel newChannel(ReadableByteChannel in) throws IOException
IOException
public static MemFileChannel newChannel(ReadableByteChannel in, String mode) throws IOException
RandomAccessFile.RandomAccessFile(File,String)
).
IOException
public int read(ByteBuffer dst) throws IOException
read
in interface ReadableByteChannel
read
in class FileChannel
IOException
public int read(ByteBuffer dst, long position) throws IOException
read
in class FileChannel
IOException
public int write(ByteBuffer src) throws IOException
write
in interface WritableByteChannel
write
in class FileChannel
IOException
public int write(ByteBuffer src, long position) throws IOException
write
in class FileChannel
IOException
public long position() throws IOException
position
in class FileChannel
IOException
public FileChannel position(long newPosition) throws IOException
position
in class FileChannel
IOException
public long size() throws IOException
size
in class FileChannel
IOException
public FileChannel truncate(long newSize) throws IOException
truncate
in class FileChannel
IOException
public void force(boolean metaData) throws IOException
force
in class FileChannel
IOException
public long transferTo(WritableByteChannel dst) throws IOException
IOException
transferTo(long,long,WritableByteChannel)
public long transferTo(long position, long count, WritableByteChannel dst) throws IOException
transferTo
in class FileChannel
IOException
public long transferTo(OutputStream dst) throws IOException
IOException
transferTo(long,long,WritableByteChannel)
public long transferTo(long position, long count, OutputStream dst) throws IOException
IOException
transferTo(long,long,WritableByteChannel)
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException
transferFrom
in class FileChannel
IOException
public long write(ByteBuffer[] srcs, int offset, int length) throws IOException
write
in interface GatheringByteChannel
write
in class FileChannel
IOException
public long read(ByteBuffer[] dsts, int offset, int length) throws IOException
read
in interface ScatteringByteChannel
read
in class FileChannel
IOException
public MappedByteBuffer map(FileChannel.MapMode mode, long position, long size) throws IOException
map
in class FileChannel
IOException
public FileLock lock(long position, long size, boolean shared) throws IOException
lock
in class FileChannel
IOException
public FileLock tryLock(long position, long size, boolean shared) throws IOException
tryLock
in class FileChannel
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |