org.javasimon
Class NullCounter

java.lang.Object
  extended by org.javasimon.NullSimon
      extended by org.javasimon.NullCounter
All Implemented Interfaces:
Counter, HasAttributes, Simon

final class NullCounter
extends NullSimon
implements Counter

Null Counter implements Simon returned by the disabled Manager.getCounter(String). It extends NullSimon to satisfy Counter interface.

Author:
Richard "Virgo" Richter

Field Summary
(package private) static NullCounter INSTANCE
          Internal singleton value of the null Counter.
 
Constructor Summary
private NullCounter()
           
 
Method Summary
 Counter decrease()
          Decrements the counter by one.
 Counter decrease(long dec)
          Increments the counter by the specified value.
 long getCounter()
          Returns the current value of the counter.
 long getDecrementSum()
          Returns the sum of all decremented values (as a positive number).
 long getIncrementSum()
          Returns the sum of all incremented values.
 long getMax()
          Returns maximal value of counter.
 long getMaxTimestamp()
          Returns ms timestamp when the max value was reached.
 long getMin()
          Returns minimal value of counter.
 long getMinTimestamp()
          Returns ms timestamp when the min value was reached.
 Counter increase()
          Increments the counter by one.
 Counter increase(long inc)
          Increments the counter by the specified value.
 NullCounter reset()
          Resets the Simon values related to the measuring, timestamps and so on - usage timestamps, state, attributes are not affected.
 CounterSample sample()
          Samples Simon values and returns them in a Java Bean derived from Sample interface.
 CounterSample sampleAndReset()
          Samples Simon values and returns them in a Java Bean derived from Sample interface and resets the Simon.
 Counter set(long val)
          Sets the value of the counter to specified value.
 
Methods inherited from class org.javasimon.NullSimon
getAttribute, getAttribute, getAttributeNames, getCopyAsSortedMap, getFirstUsage, getChildren, getLastReset, getLastUsage, getName, getNote, getParent, getState, isEnabled, removeAttribute, setAttribute, setNote, setState, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.javasimon.Simon
getFirstUsage, getChildren, getLastReset, getLastUsage, getName, getNote, getParent, getState, isEnabled, setNote, setState
 
Methods inherited from interface org.javasimon.HasAttributes
getAttribute, getAttribute, getAttributeNames, getCopyAsSortedMap, removeAttribute, setAttribute
 

Field Detail

INSTANCE

static final NullCounter INSTANCE
Internal singleton value of the null Counter. Null Counter is never directly used in the client code, it is always hidden behind the Counter interface - only its behavior manifests to the client.

Constructor Detail

NullCounter

private NullCounter()
Method Detail

reset

public NullCounter reset()
Description copied from interface: Simon
Resets the Simon values related to the measuring, timestamps and so on - usage timestamps, state, attributes are not affected. Timestamp of the last reset can be obtained by the method Simon.getLastReset(). Reset is perfomed even for disabled Simons.

Specified by:
reset in interface Counter
Specified by:
reset in interface Simon
Overrides:
reset in class NullSimon
Returns:
returns this

set

public Counter set(long val)
Description copied from interface: Counter
Sets the value of the counter to specified value.

Specified by:
set in interface Counter
Parameters:
val - new counter value
Returns:
this

increase

public Counter increase()
Description copied from interface: Counter
Increments the counter by one.

Specified by:
increase in interface Counter
Returns:
this

decrease

public Counter decrease()
Description copied from interface: Counter
Decrements the counter by one.

Specified by:
decrease in interface Counter
Returns:
this

increase

public Counter increase(long inc)
Description copied from interface: Counter
Increments the counter by the specified value.

Specified by:
increase in interface Counter
Parameters:
inc - added value
Returns:
this

decrease

public Counter decrease(long dec)
Description copied from interface: Counter
Increments the counter by the specified value.

Specified by:
decrease in interface Counter
Parameters:
dec - subtracted value
Returns:
this

getCounter

public long getCounter()
Description copied from interface: Counter
Returns the current value of the counter.

Specified by:
getCounter in interface Counter
Returns:
counter value

getMin

public long getMin()
Description copied from interface: Counter
Returns minimal value of counter.

Specified by:
getMin in interface Counter
Returns:
maximal reached value

getMax

public long getMax()
Description copied from interface: Counter
Returns maximal value of counter.

Specified by:
getMax in interface Counter
Returns:
maximal reached value

getMaxTimestamp

public long getMaxTimestamp()
Description copied from interface: Counter
Returns ms timestamp when the max value was reached.

Specified by:
getMaxTimestamp in interface Counter
Returns:
ms timestamp of the max value incremented

getMinTimestamp

public long getMinTimestamp()
Description copied from interface: Counter
Returns ms timestamp when the min value was reached.

Specified by:
getMinTimestamp in interface Counter
Returns:
ms timestamp of the min value decremented

getIncrementSum

public long getIncrementSum()
Description copied from interface: Counter
Returns the sum of all incremented values. If incremented value was negative, sum is lowered by this value.

Specified by:
getIncrementSum in interface Counter
Returns:
sum of all incremented values

getDecrementSum

public long getDecrementSum()
Description copied from interface: Counter
Returns the sum of all decremented values (as a positive number). If decremented value was negative, sum is lowered by this value.

Specified by:
getDecrementSum in interface Counter
Returns:
sum of all decremented values

sample

public CounterSample sample()
Description copied from interface: Simon
Samples Simon values and returns them in a Java Bean derived from Sample interface.

Specified by:
sample in interface Counter
Specified by:
sample in interface Simon
Overrides:
sample in class NullSimon
Returns:
sample containing all Simon values

sampleAndReset

public CounterSample sampleAndReset()
Description copied from interface: Simon
Samples Simon values and returns them in a Java Bean derived from Sample interface and resets the Simon. Operation is synchronized to assure atomicity.

Specified by:
sampleAndReset in interface Counter
Specified by:
sampleAndReset in interface Simon
Overrides:
sampleAndReset in class NullSimon
Returns:
sample containing all Simon values


Copyright © 2013. All Rights Reserved.