public final class StructuredFileOperations extends Object implements org.jdtaus.core.io.StructuredFile
StructuredFile
implementation based on FileOperations
.
Pre FlushableFileOperations
and its implementations this
implementation performed read-ahead caching. This behaviour got changed
in favour of ReadAheadFileOperations
and
CoalescingFileOperations
which are generalized replacements for any
cacheing formerly performed by this implementation. Since this class does
not implement any cacheing anymore, the flush()
method will write
out pending changes of an underlying FlushableFileOperations
implementation, if any, by calling the corresponding flush()
method
of that FlushableFileOperations
instance.
This implementation uses task monitoring for the deleteBlocks()
and insertBlocks()
methods. Task monitoring is controlled by
property monitoringThreshold
holding the number of bytes which
need to minimally be copied to enable any task monitoring during the
copy operation (defaults to 5242880 - 5MB).
Note:
This implementation is not thread-safe and concurrent changes to the
underlying FileOperations
implementation are not supported.
CoalescingFileOperations
,
ReadAheadFileOperations
Constructor and Description |
---|
StructuredFileOperations(int blockSize,
org.jdtaus.core.io.FileOperations fileOperations)
Creates a new
StructuredFileOperations instance taking the size
of one block in byte and the FileOperations operations are to be
performed with. |
StructuredFileOperations(int blockSize,
int monitoringThreshold,
org.jdtaus.core.io.FileOperations fileOperations)
Creates a new
StructuredFileOperations instance taking the size
of one block in byte, task monitoring configuration and the
FileOperations operations are to be performed with. |
Modifier and Type | Method and Description |
---|---|
void |
addStructuredFileListener(org.jdtaus.core.io.StructuredFileListener listener) |
void |
close()
Flushes the instance and closes the
FileOperations implementation
backing the instance. |
void |
deleteBlocks(long index,
long count) |
void |
flush()
Calls the
flush() method of an underlying
FlushableFileOperations instance, if any. |
long |
getBlockCount() |
int |
getBlockSize() |
org.jdtaus.core.io.FileOperations |
getFileOperations()
Gets the
FileOperations implementation operations are performed
with. |
int |
getMonitoringThreshold()
Gets the value of property
monitoringThreshold . |
org.jdtaus.core.io.StructuredFileListener[] |
getStructuredFileListeners() |
void |
insertBlocks(long index,
long count) |
void |
readBlock(long block,
int off,
byte[] buf) |
void |
readBlock(long block,
int off,
byte[] buf,
int index,
int length) |
void |
removeStructuredFileListener(org.jdtaus.core.io.StructuredFileListener listener) |
void |
writeBlock(long block,
int off,
byte[] buf) |
void |
writeBlock(long block,
int off,
byte[] buf,
int index,
int length) |
public StructuredFileOperations(int blockSize, org.jdtaus.core.io.FileOperations fileOperations) throws IOException
StructuredFileOperations
instance taking the size
of one block in byte and the FileOperations
operations are to be
performed with.blockSize
- Number of bytes per block.fileOperations
- FileOperations
implementation to operate
on.NullPointerException
- if fileOperations
is null
.IllegalArgumentException
- if blockSize
is incompatible
with the length of fileOperations
.IOException
- if getting the length from the fileOperations
fails.public StructuredFileOperations(int blockSize, int monitoringThreshold, org.jdtaus.core.io.FileOperations fileOperations) throws IOException
StructuredFileOperations
instance taking the size
of one block in byte, task monitoring configuration and the
FileOperations
operations are to be performed with.blockSize
- Number of bytes per block.monitoringThreshold
- the mininum number of bytes to copy to start
any task monitoring.fileOperations
- FileOperations
implementation to operate
on.NullPointerException
- if fileOperations
is null
.IllegalArgumentException
- if blockSize
is incompatible
with the length of fileOperations
.IOException
- if getting the length from the fileOperations
fails.public int getBlockSize()
getBlockSize
in interface org.jdtaus.core.io.StructuredFile
public long getBlockCount() throws IOException
getBlockCount
in interface org.jdtaus.core.io.StructuredFile
IOException
public void deleteBlocks(long index, long count) throws IOException
deleteBlocks
in interface org.jdtaus.core.io.StructuredFile
IOException
public void insertBlocks(long index, long count) throws IOException
insertBlocks
in interface org.jdtaus.core.io.StructuredFile
IOException
public void readBlock(long block, int off, byte[] buf) throws IOException
readBlock
in interface org.jdtaus.core.io.StructuredFile
IOException
public void readBlock(long block, int off, byte[] buf, int index, int length) throws IOException
readBlock
in interface org.jdtaus.core.io.StructuredFile
IOException
public void writeBlock(long block, int off, byte[] buf) throws IOException
writeBlock
in interface org.jdtaus.core.io.StructuredFile
IOException
public void writeBlock(long block, int off, byte[] buf, int index, int length) throws IOException
writeBlock
in interface org.jdtaus.core.io.StructuredFile
IOException
public void close() throws IOException
FileOperations
implementation
backing the instance.close
in interface org.jdtaus.core.io.StructuredFile
IOException
- if closing the FileOperations
implementation
backing the instance fails, or if the instance already is closed.public void addStructuredFileListener(org.jdtaus.core.io.StructuredFileListener listener)
addStructuredFileListener
in interface org.jdtaus.core.io.StructuredFile
public void removeStructuredFileListener(org.jdtaus.core.io.StructuredFileListener listener)
removeStructuredFileListener
in interface org.jdtaus.core.io.StructuredFile
public org.jdtaus.core.io.StructuredFileListener[] getStructuredFileListeners()
getStructuredFileListeners
in interface org.jdtaus.core.io.StructuredFile
public org.jdtaus.core.io.FileOperations getFileOperations()
FileOperations
implementation operations are performed
with.FileOperations
implementation operations are
performed with.public void flush() throws IOException
flush()
method of an underlying
FlushableFileOperations
instance, if any.IOException
- if reading or writing fails.public int getMonitoringThreshold()
monitoringThreshold
.Copyright © 2005-2012 jDTAUS. All Rights Reserved.