org.csc.phynixx.tutorial
Class UTFWriterImpl

java.lang.Object
  extended by org.csc.phynixx.tutorial.UTFWriterImpl
All Implemented Interfaces:
UTFWriter

public class UTFWriterImpl
extends Object
implements UTFWriter

Implements an quit simple an cooperating lock. To have acces to write to the file, you have to aquire a lock. If the lock is successful, you gain an lockToken. This token identifies the lock and this token enables you to release the token. If the file is lock all method to write/rad the file are unsynchronized to improve performance.


Constructor Summary
UTFWriterImpl(File file)
           
 
Method Summary
 void close()
          Schliesst die Datei und den FileChannel
 String getFilename()
           
 boolean isClosed()
          zeigt an, ob die Instanz geschlossen ist
 String lock()
           
 long position()
           
 List<String> readContent()
          reads the content
 void resetContent()
          resets the content of the file associated with die current transaction
 void restoreSize(long filePosition)
           
 long size()
           
 String toString()
           
 void unlock(String lockToken)
           
 long write(String value)
          writes a string to file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UTFWriterImpl

public UTFWriterImpl(File file)
Method Detail

lock

public String lock()
            throws InterruptedException
Specified by:
lock in interface UTFWriter
Returns:
lockToken you need to identify the unlock
Throws:
InterruptedException

unlock

public void unlock(String lockToken)
Specified by:
unlock in interface UTFWriter
Parameters:
lockToken - identifing the lock

close

public void close()
Schliesst die Datei und den FileChannel

Specified by:
close in interface UTFWriter

getFilename

public String getFilename()
                   throws IOException
Specified by:
getFilename in interface UTFWriter
Throws:
IOException

isClosed

public boolean isClosed()
zeigt an, ob die Instanz geschlossen ist

Specified by:
isClosed in interface UTFWriter
Returns:
true wenn die Datei geschlossen ist

resetContent

public void resetContent()
                  throws IOException
Description copied from interface: UTFWriter
resets the content of the file associated with die current transaction

Specified by:
resetContent in interface UTFWriter
Throws:
IOException

write

public long write(String value)
           throws IOException
Description copied from interface: UTFWriter
writes a string to file

Specified by:
write in interface UTFWriter
Returns:
Throws:
IOException

readContent

public List<String> readContent()
                         throws IOException
Description copied from interface: UTFWriter
reads the content

Specified by:
readContent in interface UTFWriter
Returns:
Throws:
IOException

size

public long size()
          throws IOException
Specified by:
size in interface UTFWriter
Throws:
IOException

restoreSize

public void restoreSize(long filePosition)
                 throws IOException
Specified by:
restoreSize in interface UTFWriter
Throws:
IOException

position

public long position()
              throws IOException
Specified by:
position in interface UTFWriter
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2015. All rights reserved.