mediautil.gen.directio
Interface ByteCounter


public interface ByteCounter

This Interface provides for tracking the number of bytes read/written. The Stream given by directio Utility classes for use by a class implementing IterativeReader/IterativeWriter implements this Interface so that the number of bytes read/written can easily be tracked without tracking each read/write/skip call.

The method to initialize read/write of the class implementing IterativeReader or IterativeWriter can check if the Stream is an instance of this Interface and setup the counter if it is.


Method Summary
 long getTotalBytes()
          This method returns the Total Number of Bytes read/written since the Creation of the Stream.
 void setCounter(int[] counterArr, boolean upMode)
          This increments/decrements the supplied integer counter as and when bytes are read/written.
 

Method Detail

setCounter

void setCounter(int[] counterArr,
                boolean upMode)
This increments/decrements the supplied integer counter as and when bytes are read/written. This method is recommended as it needs to be called only once to specify the counter during initialization of Read/Write. The initialization could check if the Supplied Stream is an instance of this Interface and the setup the counters. If not the nextRead/nextWrite call will read/write till the end since the counter will not change which is okay.

Parameters:
counterArr - Array countaining the counter. counterArr[0] will be incremented/decremented by the number of bytes as and when bytes are read/written/skipped. counterArr[0] is not changed otherwise. The application using the counter is free to reset it. For example an IterativeReader can initialize the counterArr[0] to number of bytes to be read at the beginning of the nextRead call and can check if counterArr[0] > 0 to determine if the required bytes have been read.
upMode - Pass as true to indicate the counter is to be incremented. False if it is to be decremented.

getTotalBytes

long getTotalBytes()
This method returns the Total Number of Bytes read/written since the Creation of the Stream. This is mainly for information