| java.lang.Object net.sf.jasperreports.engine.util.JRSwapFile
All known Subclasses: net.sf.jasperreports.engine.util.JRConcurrentSwapFile,
JRSwapFile | public class JRSwapFile (Code) | | Swap file implementation that can be used as a disk cache for arbitrary binary data.
Fixed-size blocks are allocated inside the swap file when a caller wants to write data.
The caller receives a handle to the allocated area based on which it can read the data
or free the area.
The implementation is thread-safe. I/O operations are performed in synchronized blocks,
only one thread would do a read or write at one moment.
author: Lucian Chirita (lucianc@users.sourceforge.net) version: $Id: JRSwapFile.java 1744 2007-06-11 14:30:11Z teodord $ |
Inner Class :protected static class LongQueue | |
Inner Class :public static class SwapHandle | |
Constructor Summary | |
public | JRSwapFile(String directory, int blockSize, int minGrowCount) Creates a swap file. |
Method Summary | |
public void | dispose() Closes and deletes the swap file. | protected void | finalize() | public void | free(SwapHandle handle) Frees an allocated area. | protected synchronized void | freeBlocks(long[] offsets) | public byte[] | read(SwapHandle handle, boolean free) Reads all the data from an allocated area. | protected void | read(byte[] data, int dataOffset, int dataLength, long fileOffset) | protected synchronized long[] | reserveFreeBlocks(int blockCount) | public SwapHandle | write(byte[] data) Allocates an area in the swap file and writes data in it. | protected void | write(byte[] data, int dataSize, int dataOffset, long fileOffset) |
JRSwapFile | public JRSwapFile(String directory, int blockSize, int minGrowCount)(Code) | | Creates a swap file.
The file name is generated automatically.
Parameters: directory - the directory where the file should be created. Parameters: blockSize - the size of the blocks allocated by the swap file Parameters: minGrowCount - the minimum number of blocks by which the swap file grows when full |
dispose | public void dispose()(Code) | | Closes and deletes the swap file.
|
free | public void free(SwapHandle handle)(Code) | | Frees an allocated area.
Parameters: handle - the allocated area handle |
freeBlocks | protected synchronized void freeBlocks(long[] offsets)(Code) | | |
read | public byte[] read(SwapHandle handle, boolean free) throws IOException(Code) | | Reads all the data from an allocated area.
Parameters: handle - the allocated area handle Parameters: free - whether to free the area after reading the whole data saved in an allocated area throws: IOException - |
read | protected void read(byte[] data, int dataOffset, int dataLength, long fileOffset) throws IOException(Code) | | |
reserveFreeBlocks | protected synchronized long[] reserveFreeBlocks(int blockCount) throws IOException(Code) | | |
write | public SwapHandle write(byte[] data) throws IOException(Code) | | Allocates an area in the swap file and writes data in it.
Parameters: data - the data for which to allocate an area in the file a handle to the allocated area throws: IOException - |
write | protected void write(byte[] data, int dataSize, int dataOffset, long fileOffset) throws IOException(Code) | | |
|
|