|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--au.com.prunge.jgenfile.impl.local.channels.RandomAccessFileChannel
A wrapper for a file channel that implements the random access set of interfaces of JGenFile.
Constructor Summary | |
RandomAccessFileChannel(FileChannel fileChannel)
Constructs a RandomAccessFileChannel . |
Method Summary | |
void |
close()
|
boolean |
equals(Object obj)
|
void |
force(boolean metaData)
|
ByteChannel |
getUnderlyingChannel()
Returns the byte channel that this channel is wrapping. |
int |
hashCode()
|
boolean |
isOpen()
|
FileLock |
lock()
|
FileLock |
lock(long position,
long size,
boolean shared)
|
MappedByteBuffer |
map(FileChannel.MapMode mode,
long position,
long size)
|
long |
position()
Returns the channel's position. |
RandomAccessChannel |
position(long newPosition)
Sets this channel's position. |
int |
read(ByteBuffer dst)
|
long |
read(ByteBuffer[] dsts)
|
long |
read(ByteBuffer[] dsts,
int offset,
int length)
|
int |
read(ByteBuffer dst,
long position)
|
long |
size()
Returns the size of this channel. |
String |
toString()
|
long |
transferFrom(ReadableByteChannel src,
long position,
long count)
|
long |
transferTo(long position,
long count,
WritableByteChannel target)
|
FileChannel |
truncate(long size)
|
FileLock |
tryLock()
|
FileLock |
tryLock(long position,
long size,
boolean shared)
|
int |
write(ByteBuffer src)
|
long |
write(ByteBuffer[] srcs)
|
long |
write(ByteBuffer[] srcs,
int offset,
int length)
|
int |
write(ByteBuffer src,
long position)
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public RandomAccessFileChannel(FileChannel fileChannel) throws NullPointerException
RandomAccessFileChannel
.
fileChannel
- the underlying file channel.
NullPointerException
- if fileChannel
is null.Method Detail |
public boolean equals(Object obj)
equals
in class Object
Object.equals(java.lang.Object)
public void force(boolean metaData) throws IOException
metaData
-
IOException
public int hashCode()
hashCode
in class Object
Object.hashCode()
public FileLock lock() throws IOException
IOException
public FileLock lock(long position, long size, boolean shared) throws IOException
position
- size
- shared
-
IOException
public MappedByteBuffer map(FileChannel.MapMode mode, long position, long size) throws IOException
mode
- position
- size
-
IOException
public int read(ByteBuffer dst, long position) throws IOException
dst
- position
-
IOException
public long read(ByteBuffer[] dsts) throws IOException
dsts
-
IOException
public long read(ByteBuffer[] dsts, int offset, int length) throws IOException
dsts
- offset
- length
-
IOException
public String toString()
toString
in class Object
Object.toString()
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException
src
- position
- count
-
IOException
public long transferTo(long position, long count, WritableByteChannel target) throws IOException
position
- count
- target
-
IOException
public FileChannel truncate(long size) throws IOException
size
-
IOException
public FileLock tryLock() throws IOException
IOException
public FileLock tryLock(long position, long size, boolean shared) throws IOException
position
- size
- shared
-
IOException
public int write(ByteBuffer src, long position) throws IOException
src
- position
-
IOException
public long write(ByteBuffer[] srcs) throws IOException
srcs
-
IOException
public long write(ByteBuffer[] srcs, int offset, int length) throws IOException
srcs
- offset
- length
-
IOException
public void close() throws IOException
close
in interface Channel
IOException
public boolean isOpen()
isOpen
in interface Channel
public long position() throws IOException
RandomAccessChannel
position
in interface RandomAccessChannel
IOException
public RandomAccessChannel position(long newPosition) throws IOException
RandomAccessChannel
Setting the position to a value that is greater than the channel's current size is legal but does not change its size. 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 channel to be grown to accomodate the new bytes; the values of any bytes between the previous end-of-file and the newly-written bytes are unspecified.
position
in interface RandomAccessChannel
newPosition
-
IOException
public int read(ByteBuffer dst) throws IOException
read
in interface ReadableByteChannel
dst
-
IOException
public long size() throws IOException
RandomAccessChannel
size
in interface RandomAccessChannel
IOException
public int write(ByteBuffer src) throws IOException
write
in interface WritableByteChannel
src
-
IOException
public ByteChannel getUnderlyingChannel()
WrappedByteChannel
getUnderlyingChannel
in interface WrappedByteChannel
WrappedByteChannel.getUnderlyingChannel()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |