org.kc7bfi.jflac.util
Class RingBuffer

java.lang.Object
  extended by org.kc7bfi.jflac.util.RingBuffer

public class RingBuffer
extends Object

RingBuffer class.

Author:
David R Robison

Field Summary
protected  byte[] buffer
           
protected  int bufferSize
           
protected static int DEFAULT_BUFFER_SIZE
           
protected  boolean eof
           
protected  int getHere
           
protected  int putHere
           
protected  Object signal
           
 
Constructor Summary
RingBuffer()
          Constructor.
RingBuffer(int size)
          Constructor.
 
Method Summary
 void empty()
          Empty the ring buffer.
 int get(byte[] data, int offset, int len)
          Read data from the ring buffer.
 int getAvailable()
          Return the bytes available for reading.
 boolean isEOF()
          Return EOF status.
static void main(String[] args)
          Test main routine.
 void put(byte[] data, int offset, int len)
          Put data into the ring buffer.
 int putAvailable()
          return the space avaiable for writing.
 void resize(int newSize)
          Resize the ring buffer.
 void setEOF(boolean eof)
          Set the EOF status.
 int size()
          Return the size of the ring buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_BUFFER_SIZE

protected static final int DEFAULT_BUFFER_SIZE
See Also:
Constant Field Values

bufferSize

protected volatile int bufferSize

buffer

protected byte[] buffer

putHere

protected volatile int putHere

getHere

protected volatile int getHere

eof

protected volatile boolean eof

signal

protected Object signal
Constructor Detail

RingBuffer

public RingBuffer(int size)
Constructor.

Parameters:
size - The size of the ring buffer

RingBuffer

public RingBuffer()
Constructor.

Method Detail

size

public int size()
Return the size of the ring buffer.

Returns:
The ring buffer size

resize

public void resize(int newSize)
Resize the ring buffer.

Parameters:
newSize - The new size of the ring buffer

putAvailable

public int putAvailable()
return the space avaiable for writing.

Returns:
The byte that may be written to the ring buffer

empty

public void empty()
Empty the ring buffer.


put

public void put(byte[] data,
                int offset,
                int len)
Put data into the ring buffer.

Parameters:
data - The data to write
offset - The start position in the data array
len - The bytes from the data array to write

getAvailable

public int getAvailable()
Return the bytes available for reading.

Returns:
The number of bytes that may be read from the ring buffer

get

public int get(byte[] data,
               int offset,
               int len)
Read data from the ring buffer.

Parameters:
data - Where to put the data
offset - The offset into the data array to start putting data
len - The maximum data to read
Returns:
The number of bytes read

isEOF

public boolean isEOF()
Return EOF status.

Returns:
True if EOF.

setEOF

public void setEOF(boolean eof)
Set the EOF status.

Parameters:
eof - The eof to set.

main

public static void main(String[] args)
Test main routine.

Parameters:
args - Not used


Copyright © 2004-2011. All Rights Reserved.