Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * See the file LICENSE for redistribution information.
   * Copyright (c) 2002, 2013 Oracle and/or its affiliates.  All rights reserved.
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.
 public abstract class Stat<T> implements CloneableSerializable {
     private static final long serialVersionUID = 1L;
     public static final DecimalFormat FORMAT =
         new DecimalFormat("###,###,###,###,###,###,###");
     protected final StatDefinition definition;

A stat registers itself with an owning group.
     Stat(StatGroup groupStatDefinition definition) {
         this. = definition;


the stat value.
     public abstract T get();

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

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

Initialize the stat to the proper value at startup, or reset the stat when copyAndClear() is called.
     public abstract void clear();
     public Stat<T> copy() {
         Object o;
         try {
             o = super.clone();
         } catch (CloneNotSupportedException unexpected) {
             throw EnvironmentFailureException.unexpectedException(unexpected);
         return (Stat<T>) o;

Return a copy of this stat, and clear the stat's value.
     public Stat<T> copyAndClear() {
         Stat<T> newCopy = copy();
         return newCopy;
     public StatDefinition getDefinition() {
         return ;

Return a string with the stat value formatted as appropriate for its type.
     abstract protected String getFormattedValue();
     public String toString() {
         return .getName() + "=" + getFormattedValue();

Includes the per-stat description in the output string.
    public String toStringVerbose() {
        return .getName() + "=" + getFormattedValue() +
            "\n\t\t" + .getDescription();

Returns true if this stat is zero or null, as is appropriate for its type.
    abstract public boolean isNotSet();
New to GrepCode? Check out our FAQ X