Package com.db4o.io
Class BinDecorator
- java.lang.Object
-
- com.db4o.io.BinDecorator
-
- All Implemented Interfaces:
Bin
- Direct Known Subclasses:
BlockAwareBin,ReadOnlyBin,SynchronizedBin,ThreadedSyncBin
public class BinDecorator extends java.lang.Object implements Bin
Wrapper baseclass for all classes that wrap Bin. Each class that adds functionality to a Bin can extend this class to allow db4o to access the delegate instance withStorageDecorator.decorate(BinConfiguration, Bin).
-
-
Constructor Summary
Constructors Constructor Description BinDecorator(Bin bin)Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()closes the BinDecorator and the underlyingBin.longlength()returns the length of the Bin (on disc, in memory).intread(long position, byte[] bytes, int bytesToRead)reads a given number of bytes into an array of bytes at an offset position.voidsync()flushes the buffer content to the physical storage media.voidsync(java.lang.Runnable runnable)runs the Runnable between two calls to sync();intsyncRead(long position, byte[] bytes, int bytesToRead)reads a given number of bytes into an array of bytes at an offset position.voidwrite(long position, byte[] bytes, int bytesToWrite)writes a given number of bytes from an array of bytes at an offset position
-
-
-
Field Detail
-
_bin
protected final Bin _bin
-
-
Method Detail
-
close
public void close()
closes the BinDecorator and the underlyingBin.
-
length
public long length()
Description copied from interface:Binreturns the length of the Bin (on disc, in memory).- Specified by:
lengthin interfaceBin- See Also:
Bin.length()
-
read
public int read(long position, byte[] bytes, int bytesToRead)Description copied from interface:Binreads a given number of bytes into an array of bytes at an offset position.- Specified by:
readin interfaceBin- Parameters:
position- the offset position to read atbytes- the byte array to read bytes intobytesToRead- the number of bytes to be read- Returns:
- The number of bytes actually read (<= bytesToRead) or -1 if position already points to/exceeds the end of the bin
- See Also:
Bin.read(long, byte[], int)
-
sync
public void sync()
Description copied from interface:Binflushes the buffer content to the physical storage media.- Specified by:
syncin interfaceBin- See Also:
Bin.sync()
-
syncRead
public int syncRead(long position, byte[] bytes, int bytesToRead)Description copied from interface:Binreads a given number of bytes into an array of bytes at an offset position. In contrast to the normalBin.read(long, byte[], int)method, the Bin should ensure direct access to the raw storage medium. No caching should take place.- Specified by:
syncReadin interfaceBin- Parameters:
position- the offset position to read atbytes- the byte array to read bytes intobytesToRead- the number of bytes to be read- Returns:
- See Also:
Bin.syncRead(long, byte[], int)
-
write
public void write(long position, byte[] bytes, int bytesToWrite)Description copied from interface:Binwrites a given number of bytes from an array of bytes at an offset position- Specified by:
writein interfaceBin- Parameters:
position- the offset position to write atbytes- the array of bytes to writebytesToWrite- the number of bytes to write- See Also:
Bin.write(long, byte[], int)
-
-