Package org.deckfour.xes.nikefs2
Class NikeFS2Block
- java.lang.Object
-
- org.deckfour.xes.nikefs2.NikeFS2Block
-
public class NikeFS2Block extends java.lang.ObjectThis class implements the abstraction of a storage block for the NikeFS2 virtual file systems. Blocks have a defined size, in number of bytes, and are the basic building blocks for virtual files.- Author:
- Christian W. Guenther (christian@deckfour.org)
-
-
Constructor Summary
Constructors Constructor Description NikeFS2Block(NikeFS2BlockProvider provider, int blockNumber)Creates a new block.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intblockNumber()Returns the index number of this block within its block provider.voidclose()Closes this block, which frees all associated resources.intread(int blockOffset)Read a single byte from this block.intread(int blockOffset, byte[] buffer)Read a number of bytes from this block.intread(int blockOffset, byte[] buffer, int offset, int length)Read a number of bytes from this block.intsize()Returns the size of this block in bytes.voidwrite(int blockOffset, byte[] buffer)Writes a number of bytes to this block.voidwrite(int blockOffset, byte[] buffer, int offset, int length)Writes a number of bytes to this block.voidwrite(int blockOffset, int value)Writes a single byte to this block.
-
-
-
Constructor Detail
-
NikeFS2Block
public NikeFS2Block(NikeFS2BlockProvider provider, int blockNumber)
Creates a new block.- Parameters:
provider- The provider of this block.blockNumber- The block number.
-
-
Method Detail
-
size
public int size()
Returns the size of this block in bytes.
-
blockNumber
public int blockNumber()
Returns the index number of this block within its block provider.
-
close
public void close()
Closes this block, which frees all associated resources.
-
read
public int read(int blockOffset, byte[] buffer, int offset, int length) throws java.io.IOExceptionRead a number of bytes from this block.- Parameters:
blockOffset- Offset, in bytes, within this block.buffer- Buffer to store read data in.offset- Offset within the buffer to write to.length- Number of bytes to be read.- Returns:
- The number of read bytes.
- Throws:
java.io.IOException
-
read
public int read(int blockOffset, byte[] buffer) throws java.io.IOExceptionRead a number of bytes from this block.- Parameters:
blockOffset- Offset, in bytes, within this block.buffer- Buffer to store read data in.- Throws:
java.io.IOException
-
read
public int read(int blockOffset) throws java.io.IOExceptionRead a single byte from this block.- Parameters:
blockOffset- Offset, in bytes, within this block.- Returns:
- The read byte.
- Throws:
java.io.IOException
-
write
public void write(int blockOffset, byte[] buffer, int offset, int length) throws java.io.IOExceptionWrites a number of bytes to this block.- Parameters:
blockOffset- Offset within the block to commence writing at.buffer- Buffer storing the data to be written.offset- Offset within the buffer from where to read.length- Number of bytes to be written.- Throws:
java.io.IOException
-
write
public void write(int blockOffset, byte[] buffer) throws java.io.IOExceptionWrites a number of bytes to this block.- Parameters:
blockOffset- Offset within the block to commence writing at.buffer- Buffer storing the data to be written.- Throws:
java.io.IOException
-
write
public void write(int blockOffset, int value) throws java.io.IOExceptionWrites a single byte to this block.- Parameters:
blockOffset- Offset within the block to commence writing at.value- The byte to be written.- Throws:
java.io.IOException
-
-