Terrier IR Platform
2.2.1

uk.ac.gla.terrier.compression
Class LinkedBuffer

java.lang.Object
  extended by uk.ac.gla.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
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
 
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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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
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 IR Platform
2.2.1

Terrier Information Retrieval Platform 2.2.1. Copyright 2004-2008 University of Glasgow