Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

java.nio.channels
Class FileLock  view FileLock download FileLock.java

java.lang.Object
  extended byjava.nio.channels.FileLock

public abstract class FileLock
extends java.lang.Object

Since:
1.4

Field Summary
private  FileChannel channel
           
private  long position
           
private  boolean shared
           
private  long size
           
 
Constructor Summary
protected FileLock(FileChannel channel, long position, long size, boolean shared)
          Initializes the file lock.
 
Method Summary
 FileChannel channel()
          Returns the file channel upon whose file this lock is held.
 boolean isShared()
          Tells whether this lock is shared.
abstract  boolean isValid()
          Tells whether or not this lock is valid.
 boolean overlaps(long position, long size)
          Tells whether or not this lock overlaps the given lock range.
 long position()
          Returns the position within the file of the first byte of the locked region.
abstract  void release()
          Releases this lock.
 long size()
          Returns the size of the locked region in bytes.
 java.lang.String toString()
          Returns a string describing the range, type, and validity of this lock.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

channel

private final FileChannel channel

position

private final long position

size

private final long size

shared

private final boolean shared
Constructor Detail

FileLock

protected FileLock(FileChannel channel,
                   long position,
                   long size,
                   boolean shared)
Initializes the file lock.

Method Detail

isValid

public abstract boolean isValid()
Tells whether or not this lock is valid.


release

public abstract void release()
                      throws java.io.IOException
Releases this lock.


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.


overlaps

public final boolean overlaps(long position,
                              long size)
Tells whether or not this lock overlaps the given lock range.


position

public final long position()
Returns the position within the file of the first byte of the locked region.


size

public final long size()
Returns the size of the locked region in bytes.


toString

public final java.lang.String toString()
Returns a string describing the range, type, and validity of this lock.