|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.ac.vamsas.client.simpleclient.Lock
uk.ac.vamsas.client.simpleclient.NativeLock
Field Summary | |
protected java.nio.channels.FileLock |
lock
|
Fields inherited from class uk.ac.vamsas.client.simpleclient.Lock |
log, rafile |
Constructor Summary | |
NativeLock(java.io.File lockfile,
boolean block)
|
Method Summary | |
protected void |
finalize()
|
java.io.BufferedOutputStream |
getBufferedOutputStream(boolean clear)
return buffered output stream to locked file. |
java.io.FileInputStream |
getFileInputStream(boolean atStart)
gets Locked Stream for reading from |
java.io.FileOutputStream |
getFileOutputStream(boolean clear)
gets Locked stream to write to FileInput always starts at the *end* of the file (after any truncation) |
java.nio.channels.FileChannel |
getRaChannel()
|
java.io.RandomAccessFile |
getRaFile()
|
boolean |
isLocked()
|
boolean |
isTargetLockFile(java.io.File afile)
test whether the given file is a target or related to the lock on the target file. |
long |
length()
safe lock target length() function. |
void |
release()
release lock and close all managed channels to file |
void |
release(boolean closeChannel)
optionally close the open random access channel on the file when releasing lock |
Methods inherited from class uk.ac.vamsas.client.simpleclient.Lock |
getBufferedInputStream |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.nio.channels.FileLock lock
Constructor Detail |
public NativeLock(java.io.File lockfile, boolean block)
lockfile
- block
- true means thread will block until a lock is obtained.Method Detail |
public boolean isLocked()
isLocked
in class Lock
public void release()
Lock
release
in class Lock
public void release(boolean closeChannel)
Lock
release
in class Lock
closeChannel
- public java.io.FileInputStream getFileInputStream(boolean atStart) throws java.io.IOException
getFileInputStream
in class Lock
atStart
- true to start reading at beginning of file.
java.io.IOException
public java.io.FileOutputStream getFileOutputStream(boolean clear) throws java.io.IOException
getFileOutputStream
in class Lock
clear
- true means file will be cleared to zero length
java.io.IOException
public java.io.BufferedOutputStream getBufferedOutputStream(boolean clear) throws java.io.IOException
getBufferedOutputStream
in class Lock
clear
- - true means file is truncated to 0 length before writing
java.io.IOException
protected void finalize() throws java.lang.Throwable
finalize
in class Lock
java.lang.Throwable
Lock.finalize()
public long length()
Lock
length
in class Lock
public java.io.RandomAccessFile getRaFile() throws java.io.IOException
getRaFile
in class Lock
java.io.IOException
public java.nio.channels.FileChannel getRaChannel() throws java.io.IOException
getRaChannel
in class Lock
java.io.IOException
public boolean isTargetLockFile(java.io.File afile)
Lock
isTargetLockFile
in class Lock
afile
- a file
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |