Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.nio.channels

Class FileLock

java.lang.Object
|
+--java.nio.channels.FileLock


public abstract class FileLock

extends Object

Since:

Constructor Summary

FileLock(java.nio.channels.FileChannel channel, long position, long size, boolean shared)

Initializes the file lock.

Method Summary

java.nio.channels.FileChannelchannel()

Returns the file channel upon whose file this lock is held.
booleanisShared()

Tells whether this lock is shared.
booleanisValid()

Tells whether or not this lock is valid.
booleanoverlaps(long position, long size)

Tells whether or not this lock overlaps the given lock range.
longposition()

Returns the position within the file of the first byte of the locked region.
voidrelease()

Releases this lock.
longsize()

Returns the size of the locked region in bytes.
java.lang.StringtoString()

Returns a string describing the range, type, and validity of this lock.

Constructor Details

FileLock

protected FileLock(java.nio.channels.FileChannel channel, long position, long size, boolean shared)

Initializes the file lock.

Parameters:

Throws:


Method Details

channel

public final FileChannel channel()

Returns the file channel upon whose file this lock is held.


isShared

public final boolean isShared()

Tells whether this lock is shared.


isValid

public boolean isValid()

Tells whether or not this lock is valid.


overlaps

public final boolean overlaps(long position, long size)

Tells whether or not this lock overlaps the given lock range.

Parameters:


position

public final long position()

Returns the position within the file of the first byte of the locked region.


release

public void release()

Releases this lock.

Throws:


size

public final long size()

Returns the size of the locked region in bytes.


toString

public final String toString()

Returns a string describing the range, type, and validity of this lock.