Package org.apache.jena.dboe.base.file
Class BinaryDataFileSync
- java.lang.Object
-
- org.apache.jena.dboe.base.file.BinaryDataFileSync
-
- All Implemented Interfaces:
org.apache.jena.atlas.lib.Closeable,org.apache.jena.atlas.lib.Sync,BinaryDataFile
public class BinaryDataFileSync extends java.lang.Object implements BinaryDataFile
Add synchronization to all BinaryDataFile operations. This gives the correct thread-safe operation but isn't necessarily the best way to do it.
-
-
Constructor Summary
Constructors Constructor Description BinaryDataFileSync(BinaryDataFile other)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()booleanisOpen()Is it open?longlength()Return the length of the file (including any buffered writes)voidopen()Open the fileintread(long posn, byte[] b)Read into a byte array, returning the number of bytes read.intread(long posn, byte[] b, int start, int length)Read into a byte array, returning the number of bytes read.voidsync()voidtruncate(long length)Truncate the filelongwrite(byte[] b)Write bytes - bytes are always written to the end of the file.longwrite(byte[] b, int start, int length)Write bytes - bytes are always written to the end of the file.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.jena.dboe.base.file.BinaryDataFile
isEmpty
-
-
-
-
Constructor Detail
-
BinaryDataFileSync
public BinaryDataFileSync(BinaryDataFile other)
-
-
Method Detail
-
open
public void open()
Description copied from interface:BinaryDataFileOpen the file- Specified by:
openin interfaceBinaryDataFile
-
isOpen
public boolean isOpen()
Description copied from interface:BinaryDataFileIs it open?- Specified by:
isOpenin interfaceBinaryDataFile
-
read
public int read(long posn, byte[] b)Description copied from interface:BinaryDataFileRead into a byte array, returning the number of bytes read. Reads are at an absolute position and a read is atomic/thread-safe.- Specified by:
readin interfaceBinaryDataFile- Parameters:
posn- Location of the read operation.b- byte array- Returns:
- The number of bytes read
-
read
public int read(long posn, byte[] b, int start, int length)Description copied from interface:BinaryDataFileRead into a byte array, returning the number of bytes read. Reads are at an absolute position and a read is atomic/thread-safe.- Specified by:
readin interfaceBinaryDataFile- Parameters:
posn- Location of the read operation.start- of bytesarray to read intolength- Maximum number of bytes to read.- Returns:
- The number of bytes read
-
write
public long write(byte[] b)
Description copied from interface:BinaryDataFileWrite bytes - bytes are always written to the end of the file. Return the location where the write started.- Specified by:
writein interfaceBinaryDataFile
-
write
public long write(byte[] b, int start, int length)Description copied from interface:BinaryDataFileWrite bytes - bytes are always written to the end of the file. Return the location where the write started.- Specified by:
writein interfaceBinaryDataFile
-
length
public long length()
Description copied from interface:BinaryDataFileReturn the length of the file (including any buffered writes)- Specified by:
lengthin interfaceBinaryDataFile
-
truncate
public void truncate(long length)
Description copied from interface:BinaryDataFileTruncate the file- Specified by:
truncatein interfaceBinaryDataFile
-
sync
public void sync()
- Specified by:
syncin interfaceBinaryDataFile- Specified by:
syncin interfaceorg.apache.jena.atlas.lib.Sync
-
close
public void close()
- Specified by:
closein interfaceBinaryDataFile- Specified by:
closein interfaceorg.apache.jena.atlas.lib.Closeable
-
-