org.jrabbit.standard.profiler.util
Class ValueTracker<T>

java.lang.Object
  extended by org.jrabbit.standard.profiler.util.Message
      extended by org.jrabbit.standard.profiler.util.ValueTracker<T>
All Implemented Interfaces:
Referenced

public class ValueTracker<T>
extends Message

A ValueTracker extends Message to maintain a message displaying a particular value. Its message only changes whenever the value it is told to display is different than the one it currently has. This class is most useful for tracking quantities or similar types of data.

Author:
Chris Molini

Field Summary
protected  T value
          The current value being used.
 
Fields inherited from class org.jrabbit.standard.profiler.util.Message
listener, message, reference
 
Constructor Summary
ValueTracker(java.lang.String reference)
          Creates a ValueTracker that is identified by the supplied reference and begins with an initial value of null.
ValueTracker(java.lang.String reference, T value)
          Creates a ValueTracker that is identified by the supplied reference and begins with the supplied value.
 
Method Summary
 void setValue(T value)
          If the supplied value is different that the current one, updates the messages and references accordingly.
 T value()
          Learns the current value being displayed.
 
Methods inherited from class org.jrabbit.standard.profiler.util.Message
alertListener, listener, message, reference, setListener, setMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

value

protected T value
The current value being used.

Constructor Detail

ValueTracker

public ValueTracker(java.lang.String reference)
Creates a ValueTracker that is identified by the supplied reference and begins with an initial value of null.

Parameters:
reference - The String that identifies the ValueTracker.

ValueTracker

public ValueTracker(java.lang.String reference,
                    T value)
Creates a ValueTracker that is identified by the supplied reference and begins with the supplied value.

Parameters:
reference - The String that identifies the ValueTracker.
value - The initial value to display.
Method Detail

value

public T value()
Learns the current value being displayed.

Returns:
The object that is currently being displayed in String form.

setValue

public void setValue(T value)
If the supplied value is different that the current one, updates the messages and references accordingly.

Parameters:
value - The new value to display.