net.sf.colossus.util
Class ValueRecorder

java.lang.Object
  extended by net.sf.colossus.util.ValueRecorder
All Implemented Interfaces:
IValueRecorderItem

public class ValueRecorder
extends java.lang.Object
implements IValueRecorderItem

An integer value, along with a detailed record of how and why the value has the value it has.

Author:
Romain Dolbeau

Nested Class Summary
private  class ValueRecorder.TrivialValueRecorderItem
           
 
Field Summary
private  java.lang.String desc
           
private  java.util.List<IValueRecorderItem> items
          All the explanations and value changes
private  float scale
           
private  int value
          The current value
 
Constructor Summary
ValueRecorder()
           
ValueRecorder(java.lang.String desc)
           
 
Method Summary
 void add(int v, java.lang.String r)
          Augment the value.
 void add(ValueRecorder v)
          Augment the value.
 java.lang.String getFull(java.lang.String prefix)
           
 int getValue()
          Get the value.
 java.lang.String getWhy(java.lang.String prefix)
           
 boolean isEmpty()
           
 boolean isReset()
           
 void resetTo(int v, java.lang.String r)
          Reset the value to a specific value.
 void setScale(float scale)
           
 java.lang.String toString()
          Get the detailed explanations and final value as String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

value

private int value
The current value


scale

private float scale

desc

private final java.lang.String desc

items

private final java.util.List<IValueRecorderItem> items
All the explanations and value changes

Constructor Detail

ValueRecorder

public ValueRecorder()

ValueRecorder

public ValueRecorder(java.lang.String desc)
Method Detail

isReset

public boolean isReset()
Specified by:
isReset in interface IValueRecorderItem

add

public void add(int v,
                java.lang.String r)
Augment the value.

Parameters:
v - By how much the value change.
r - The reason of the change.

add

public void add(ValueRecorder v)
Augment the value.

Parameters:
v - By how much the value change, and why

resetTo

public void resetTo(int v,
                    java.lang.String r)
Reset the value to a specific value.

Parameters:
v - The new value to use.
r - The reason of the change.

getValue

public int getValue()
Get the value.

Specified by:
getValue in interface IValueRecorderItem
Returns:
The current value.

setScale

public void setScale(float scale)

isEmpty

public boolean isEmpty()

getWhy

public java.lang.String getWhy(java.lang.String prefix)
Specified by:
getWhy in interface IValueRecorderItem

getFull

public java.lang.String getFull(java.lang.String prefix)
Specified by:
getFull in interface IValueRecorderItem

toString

public java.lang.String toString()
Get the detailed explanations and final value as String.

Overrides:
toString in class java.lang.Object
Returns:
The detailed explanations and final value.