org.jdtaus.core.io
Interface StructuredFile


public interface StructuredFile

Block oriented I/O operations.

Version:
$Id: StructuredFile.java 1914 2007-03-01 02:20:44Z schulte2005 $
Author:
Christian Schulte

Method Summary
 void addStructuredFileListener(StructuredFileListener listener)
          Adds a to the listener list.
 void deleteBlocks(long index, long count)
          Removes blocks.
 long getBlockCount()
          Reads the total amount of existing blocks.
 int getBlockSize()
          Reads the length of one block in byte.
 StructuredFileListener[] getStructuredFileListeners()
          Accessor to all currently registered s.
 void insertBlocks(long index, long count)
          Inserts new blocks.
 void readBlock(long block, int off, byte[] buf)
          Reads byte starting at position in .
 void readBlock(long block, int off, byte[] buf, int index, int length)
          Reads byte starting at position in into starting at inclusive.
 void removeStructuredFileListener(StructuredFileListener listener)
          Removes a from the listener list.
 void writeBlock(long block, int off, byte[] buf)
          Writes byte from into starting at inclusive.
 void writeBlock(long block, int off, byte[] buf, int index, int length)
          Writes byte from starting at inclusive into starting at inclusive.
 

Method Detail

addStructuredFileListener

public void addStructuredFileListener(StructuredFileListener listener)
Adds a to the listener list.

Parameters:
listener - The listener to be added to the listener list.
Throws:
NullPointerException - if is .

deleteBlocks

public void deleteBlocks(long index,
                         long count)
                  throws IOException
Removes blocks. The new index of the block previously at will be at .

Parameters:
index - index of the first block to start removing blocks.
count - number of blocks to remove.
Throws:
IndexOutOfBoundsException - if is negative or is negative or zero or is greater than .
IOException - if deleting blocks fails.

getBlockCount

public long getBlockCount()
                   throws IOException
Reads the total amount of existing blocks.

Returns:
total amount of existing blocks.
Throws:
IOException - if getting the block count fails.

getBlockSize

public int getBlockSize()
                 throws IOException
Reads the length of one block in byte.

Returns:
length of one block in byte.
Throws:
IOException - if getting the block size fails.

getStructuredFileListeners

public StructuredFileListener[] getStructuredFileListeners()
Accessor to all currently registered s.

Returns:
all currently registered s.

insertBlocks

public void insertBlocks(long index,
                         long count)
                  throws IOException
Inserts new blocks. The content of the new blocks is not further specified. The new index of the block previously at will be at .

Parameters:
index - index of the first new block.
count - number of blocks to insert starting at .
Throws:
IndexOutOfBoundsException - if or is negativ or is greater than or is zero or greater than .
IOException - if inserting blocks fails.

readBlock

public void readBlock(long block,
                      int off,
                      byte[] buf)
               throws IOException
Reads byte starting at position in . Same as .

Parameters:
block - index of the block to read data from.
off - starting offset to the data to read from .
buf - array to store the data in.
Throws:
NullPointerException - if is .
IndexOutOfBoundsException - if is negative, greater than or equal to , or is negative, greater than or equal to , or the length of is greater than .
IOException - if reading fails.

readBlock

public void readBlock(long block,
                      int off,
                      byte[] buf,
                      int index,
                      int length)
               throws IOException
Reads byte starting at position in into starting at inclusive.

Parameters:
block - index of the block to read data from.
off - starting offset of the data to read from .
buf - array to store the data in.
index - offset to start writing data into .
length - number of byte to read.
Throws:
NullPointerException - if is .
IndexOutOfBoundsException - if is negative, greater than or equal to , or is negative, greater than or equal to , or is negative, greater than or equal to the length of , or is negative or greater than the length of minus or greater than .
IOException - if reading fails.

removeStructuredFileListener

public void removeStructuredFileListener(StructuredFileListener listener)
Removes a from the listener list.

Parameters:
listener - The listener to be removed from the listener list.
Throws:
NullPointerException - if is .

writeBlock

public void writeBlock(long block,
                       int off,
                       byte[] buf)
                throws IOException
Writes byte from into starting at inclusive. Same as .

Parameters:
block - index of the block to write into.
off - inclusive offset to start writing into .
buf - data to write into beginning at .
Throws:
NullPointerException - if is .
IndexOutOfBoundsException - if is negative, greater than or equal to , or is greater than or equal to , or the length of is greater than .
IOException - if writing fails.

writeBlock

public void writeBlock(long block,
                       int off,
                       byte[] buf,
                       int index,
                       int length)
                throws IOException
Writes byte from starting at inclusive into starting at inclusive.

Parameters:
block - index of the block to write into.
off - inclusive offset to start writing into .
buf - data to write into beginning at .
index - inclusive offset to start reading data from .
length - number of byte to read from starting at .
Throws:
NullPointerException - if is .
IndexOutOfBoundsException - if is negative, greater than or equal to , or is negative, greater than or equal to , or is negative, greater than or equal to the length of , or is negative or greater than the length of minus or greater than .
IOException - if writing fails.


Copyright © 2005-2007 jDTAUS. All Rights Reserved.