org.ssonet.util
Class ByteFIFO

java.lang.Object
  |
  +--org.ssonet.util.ByteFIFO

public class ByteFIFO
extends java.lang.Object

Class providing fifo operations using byte array as a buffer


Constructor Summary
ByteFIFO(int buffSize)
          Creates the FIFO object with the given size of the buffer
 
Method Summary
 int available()
           
 int getBuffSize()
           
 int read(byte[] readBuffer)
          Reads data into a given byte-array.
 int read(byte[] readBuffer, int off, int blen)
          Reads data into a given byte-array.
 byte[] read(int byteCount)
          Reads an array of bytes from the FIFO
 void write(byte[] bytes)
          Writes an array of bytes to the FIFO.
 void write(byte[] bytes, int start2, int length)
          Writes length bytes from a byte-array to the FIFO, beginning with start index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteFIFO

public ByteFIFO(int buffSize)
Creates the FIFO object with the given size of the buffer

Parameters:
buffSize - the buffer size
Method Detail

write

public void write(byte[] bytes)
           throws java.io.IOException
Writes an array of bytes to the FIFO.

Parameters:
bytes - the array of bytes
Throws:
java.io.IOException - if the array doesn't fit into the fifo buffer

write

public void write(byte[] bytes,
                  int start2,
                  int length)
           throws java.io.IOException
Writes length bytes from a byte-array to the FIFO, beginning with start index.

If the start index is greater than the number of bytes in the array, nothing is written.

If start+length is greater than the number of bytes in the array, all bytes beginning at the start index until the end of the array are written.

Parameters:
start2 - the start index in the byte-array for the bytes to be written
length - the number of bytes to be written
bytes - the array of bytes
Throws:
java.io.IOException - if the number of bytes to be written doesn't fit into the fifo buffer

read

public byte[] read(int byteCount)
            throws java.io.IOException
Reads an array of bytes from the FIFO

Parameters:
byteCount - the number of bytes to read from the fifo
Throws:
java.io.IOException - if there are less bytes in the buffer than byteCount

read

public int read(byte[] readBuffer)
Reads data into a given byte-array. It returns the amount of bytes stored into the array. Caution: It doesn't throw exceptions, i.e. the parameters have to be right.

Parameters:
readBuffer - buffer for storing the data
Returns:
the number of bytes stored into the array.

read

public int read(byte[] readBuffer,
                int off,
                int blen)
Reads data into a given byte-array. It returns the amount of bytes stored into the array. Caution: It doesn't throw exceptions, i.e. the parameters have to be right.

Parameters:
readBuffer - buffer for storing the data
off - Offset which describes at which index to start storing bytes into the buffer
blen - maximum amount of bytes, which can be stored in the buffer
Returns:
the number of bytes stored into the array.

getBuffSize

public int getBuffSize()
Returns:
the size of the fifo buffer

available

public int available()
Returns:
the number of bytes currently stored in the buffer.


Copyright © 2003 DRIM Team. All Rights Reserved.