com.sleepycat.je.utilint
Class Stat<T>

java.lang.Object
  extended by com.sleepycat.je.utilint.Stat<T>
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
ActiveTxnArrayStat, AtomicIntStat, AtomicLongStat, BooleanStat, FloatStat, IntStat, LongArrayStat, LongStat, StringStat

public abstract class Stat<T>
extends Object
implements Cloneable, Serializable

Base class for all JE statistics. A single Stat embodies a value and definition. See StatGroup for a description of how to create and display statistics. Note that Stat intentionally does not contain the statistics value itself. Instead, the concrete subclass will implement the value as the appropriate primitive type. That's done to avoid wrapper classes like Integer and Long, and to keep the overhead of statistics low.

See Also:
Serialized Form

Field Summary
protected  StatDefinition definition
           
static DecimalFormat FORMAT
           
 
Constructor Summary
Stat(StatGroup group, StatDefinition definition)
          A stat registers itself with an owning group.
 
Method Summary
abstract  void add(Stat<T> other)
          Add the value of "other" to this stat.
abstract  void clear()
          Initialize the stat to the proper value at startup, or reset the stat when copyAndClear() is called.
 Stat<T> copy()
           
 Stat<T> copyAndClear()
          Return a copy of this stat, and clear the stat's value.
abstract  T get()
           
 StatDefinition getDefinition()
           
protected abstract  String getFormattedValue()
          Return a string with the stat value formatted as appropriate for its type.
abstract  boolean isNotSet()
          Returns true if this stat is zero or null, as is appropriate for its type.
abstract  void set(T newValue)
          Set the stat value.
 String toString()
           
 String toStringVerbose()
          Includes the per-stat description in the output string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FORMAT

public static final DecimalFormat FORMAT

definition

protected final StatDefinition definition
Constructor Detail

Stat

Stat(StatGroup group,
     StatDefinition definition)
A stat registers itself with an owning group.

Method Detail

get

public abstract T get()
Returns:
the stat value.

set

public abstract void set(T newValue)
Set the stat value.


add

public abstract void add(Stat<T> other)
Add the value of "other" to this stat.


clear

public abstract void clear()
Initialize the stat to the proper value at startup, or reset the stat when copyAndClear() is called.


copy

public Stat<T> copy()

copyAndClear

public Stat<T> copyAndClear()
Return a copy of this stat, and clear the stat's value.


getDefinition

public StatDefinition getDefinition()

getFormattedValue

protected abstract String getFormattedValue()
Return a string with the stat value formatted as appropriate for its type.


toString

public String toString()
Overrides:
toString in class Object

toStringVerbose

public String toStringVerbose()
Includes the per-stat description in the output string.


isNotSet

public abstract boolean isNotSet()
Returns true if this stat is zero or null, as is appropriate for its type.



Copyright (c) 2004-2012 Oracle. All rights reserved.