Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.util
Class GenericBuffer<T>

java.lang.Object
  extended by net.java.sip.communicator.util.GenericBuffer<T>

public class GenericBuffer<T>
extends Object

The GenericBuffer class provides a way to minimize the effort needed to buffer any kind of information. This class is particularly suited to optimizations based on reusing already computed data.

Author:
Benoit Pradelle

Constructor Summary
GenericBuffer(int bufferSize)
          Sole constructor.
 
Method Summary
 void addValue(T value, String context)
          Adds a value to the buffer.
 T getValue(String context)
          Retrieves the value in the buffer corresponding to the context if it exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericBuffer

public GenericBuffer(int bufferSize)
Sole constructor.

Parameters:
bufferSize - The buffer size. Adding data to a full buffer will cause the oldest data present in the buffer to be overwritten;
Method Detail

addValue

public void addValue(T value,
                     String context)
Adds a value to the buffer. If the buffer is full, the oldest value in the buffer will be overwritten by this new value.

Parameters:
value - The value to add. Can't be null.
context - The context for which this value is valid. This basically represents the current value of all the variables which control the value is correct. The context is used to find this value in the buffer. If the context is already associated in the buffer with a value, nothing is added nor modified.

getValue

public T getValue(String context)
Retrieves the value in the buffer corresponding to the context if it exists.

Parameters:
context - The context of the searched value. The context represents all the variables values for which this value is correct.
Returns:
The bufferized value with the searched context if it exists or null if no value is found.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.