org.terrier.compression
Class LinkedBuffer

java.lang.Object
  extended by org.terrier.compression.LinkedBuffer

public class LinkedBuffer
extends java.lang.Object

Implements an element of a linked list that contains a byte array

Author:
Roi Blanco

Field Summary
protected  byte[] buffer
          The internal buffer.
protected  int bufferSize
          The size of the internal buffer
static int DEFAULT_BUFFER_SIZE
          The default size of the internal buffer in bytes The buffer has to be big enough to allocate a single write, i.e we cannot write *at once* more than bufferSize bytes
protected  LinkedBuffer next
          The next buffer in the list
 
Constructor Summary
LinkedBuffer()
          Default Constructor.
LinkedBuffer(int _bufferSize)
          Constructor
 
Method Summary
 byte[] getBuffer()
           
 int getBufferSize()
           
 LinkedBuffer getNext()
           
 int getPosition()
           
 void setNext(LinkedBuffer _next)
          Set the next buffer in the list
 boolean write(int b)
          Writes a byte in the buffer
 boolean writeByte(byte b)
          Writes a byte in the buffer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buffer

protected byte[] buffer
The internal buffer.


bufferSize

protected int bufferSize
The size of the internal buffer


DEFAULT_BUFFER_SIZE

public static final int DEFAULT_BUFFER_SIZE
The default size of the internal buffer in bytes The buffer has to be big enough to allocate a single write, i.e we cannot write *at once* more than bufferSize bytes

See Also:
Constant Field Values

next

protected LinkedBuffer next
The next buffer in the list

Constructor Detail

LinkedBuffer

public LinkedBuffer()
Default Constructor. Uses a buffer of DEFAULT_BUFFER_SIZE bytes size.


LinkedBuffer

public LinkedBuffer(int _bufferSize)
Constructor

Parameters:
_bufferSize - size in bytes of the buffer.
Method Detail

getNext

public LinkedBuffer getNext()
Returns:
the next linked buffer in the list (or null)

setNext

public void setNext(LinkedBuffer _next)
Set the next buffer in the list

Parameters:
_next - next LinkedBuffer in the list

write

public boolean write(int b)
              throws java.io.IOException
Writes a byte in the buffer

Parameters:
b - int containing the byte to write
Returns:
true iff the buffer has used all its capacity
Throws:
java.io.IOException

writeByte

public boolean writeByte(byte b)
                  throws java.io.IOException
Writes a byte in the buffer

Parameters:
b - byte to write
Returns:
true iff the buffer has used all its capacity
Throws:
java.io.IOException

getBufferSize

public int getBufferSize()
Returns:
The size of the buffer

getPosition

public int getPosition()
Returns:
The current position in the buffer

getBuffer

public byte[] getBuffer()
Returns:
The byte buffer (byte[])


Terrier 3.5. Copyright © 2004-2011 University of Glasgow