messif.statistics
Class StatisticRefCounter

java.lang.Object
  extended by messif.statistics.Statistics<StatisticRefCounter>
      extended by messif.statistics.StatisticRefCounter
All Implemented Interfaces:
java.io.Serializable

public final class StatisticRefCounter
extends Statistics<StatisticRefCounter>

See Also:
Serialized Form

Field Summary
protected  java.util.Map<java.lang.Object,StatisticCounter> values
          Reference counter data
 
Fields inherited from class messif.statistics.Statistics
replaceWith
 
Constructor Summary
protected StatisticRefCounter(java.lang.String name)
          Creates a new instance of StatisticRefCounter
 
Method Summary
 void add(java.lang.Object key)
           
 void add(java.lang.Object key, long value)
          Adds the passed value to the current value associated with the passed key.
 void bindTo(StatisticCounter object, java.lang.Object key)
          Bind current statistics object to receive notifications at the same time as the specified statistics receives some.
 void bindTo(StatisticRefCounter object)
          Bind current statistics object to receive notifications at the same time as the specified statistics receives some.
protected  StatisticRefCounter cast()
          Returns this statistics as the type provided typed argument.
 void clear()
           
 boolean containsKey(java.lang.Object key)
           
 long get(java.lang.Object key)
          Reference counter read operations
 int getKeyCount()
           
 java.util.Set<java.lang.Object> getKeys()
           
protected  StatisticCounter getStatisticCounter(java.lang.Object key, boolean createIfNotExist)
          Return the statistic counter associated with the provided key.
protected  StatisticCounter getStatisticCounter(java.lang.Object key, boolean createIfNotExist, long initialValue)
          Return the statistic counter associated with the provided key.
static StatisticRefCounter getStatistics(java.lang.String name)
          Create new statistic object with specified name or get the one already existing
 boolean changedSinceCheckpoint()
          Reports if value of refCounter has been changed since the last setCheckpoint() call.
 void max(java.lang.Object key, long value)
          Set the passed value to the current value associated with the passed key if it is greater than current value.
 void min(java.lang.Object key, long value)
          Set the passed value to the current value associated with the passed key if it is smaller than current value.
 StatisticCounter remove(java.lang.Object key)
          Return either the StatisticCounter for given key and remove it from the mapping or return null, if the key is not in the map
 void reset()
          Reset the current statistic (this one only).
 void set(java.lang.Object key, long value)
          Reference counter modification operations
protected  void setFrom(StatisticRefCounter sourceStat)
          Set the value of this statistic to the actual value of the given sourceStat.
 void setCheckpoint()
          Sets checkpoint.
 void sub(java.lang.Object key)
           
 void sub(java.lang.Object key, long value)
           
 java.lang.String toString()
          Text representation
 void unbind()
          RefCounter binding overrides
 void unbind(java.lang.Object key)
          Deregister statistic counter for key from the binding list
protected  void updateFrom(StatisticRefCounter sourceStat)
          Statistics merging
 
Methods inherited from class messif.statistics.Statistics
addBoundStat, canPerformOperation, disableGlobally, enableGlobally, getAllStatistics, getAllStatistics, getBoundStats, getBoundTo, getName, getStatistics, isBound, isEnabledGlobally, isRegisteredGlobally, printStatistics, printStatistics, printStatistics, readResolve, removeBoundStat, removeStatistic, resetStatistics, resetStatistics
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

values

protected java.util.Map<java.lang.Object,StatisticCounter> values
Reference counter data

Constructor Detail

StatisticRefCounter

protected StatisticRefCounter(java.lang.String name)
Creates a new instance of StatisticRefCounter

Method Detail

get

public long get(java.lang.Object key)
Reference counter read operations


getKeys

public java.util.Set<java.lang.Object> getKeys()

getKeyCount

public int getKeyCount()

containsKey

public boolean containsKey(java.lang.Object key)

getStatisticCounter

protected StatisticCounter getStatisticCounter(java.lang.Object key,
                                               boolean createIfNotExist,
                                               long initialValue)
Return the statistic counter associated with the provided key.

Parameters:
key - the reference key of the retrieved counter
Returns:
either the StatisticsCounter or null if there is no associated counter yet

getStatisticCounter

protected StatisticCounter getStatisticCounter(java.lang.Object key,
                                               boolean createIfNotExist)
Return the statistic counter associated with the provided key.

Parameters:
key - the reference key of the retrieved counter
Returns:
either the StatisticsCounter or null if there is no associated counter yet

set

public void set(java.lang.Object key,
                long value)
Reference counter modification operations


remove

public StatisticCounter remove(java.lang.Object key)
Return either the StatisticCounter for given key and remove it from the mapping or return null, if the key is not in the map


add

public void add(java.lang.Object key,
                long value)
Adds the passed value to the current value associated with the passed key.


add

public void add(java.lang.Object key)

sub

public void sub(java.lang.Object key,
                long value)

sub

public void sub(java.lang.Object key)

max

public void max(java.lang.Object key,
                long value)
Set the passed value to the current value associated with the passed key if it is greater than current value.


min

public void min(java.lang.Object key,
                long value)
Set the passed value to the current value associated with the passed key if it is smaller than current value.


clear

public void clear()

updateFrom

protected void updateFrom(StatisticRefCounter sourceStat)
Statistics merging

Specified by:
updateFrom in class Statistics<StatisticRefCounter>
Parameters:
sourceStat - the statistic from which to update this stat

setFrom

protected void setFrom(StatisticRefCounter sourceStat)
Description copied from class: Statistics
Set the value of this statistic to the actual value of the given sourceStat.

Specified by:
setFrom in class Statistics<StatisticRefCounter>
Parameters:
sourceStat - the statistic from which to set this stat

reset

public void reset()
Reset the current statistic (this one only).

Specified by:
reset in class Statistics<StatisticRefCounter>

bindTo

public void bindTo(StatisticCounter object,
                   java.lang.Object key)
            throws java.lang.IllegalArgumentException
Bind current statistics object to receive notifications at the same time as the specified statistics receives some.

Parameters:
object - the parent statistics counter object
key - the reference key of our counter to bind it to
Throws:
java.lang.IllegalArgumentException

unbind

public void unbind(java.lang.Object key)
Deregister statistic counter for key from the binding list


unbind

public void unbind()
RefCounter binding overrides

Overrides:
unbind in class Statistics<StatisticRefCounter>

bindTo

public void bindTo(StatisticRefCounter object)
            throws java.lang.IllegalArgumentException
Bind current statistics object to receive notifications at the same time as the specified statistics receives some.

Overrides:
bindTo in class Statistics<StatisticRefCounter>
Parameters:
object - the parent statistics object
Throws:
java.lang.IllegalArgumentException - if this statistic is already bound to another stat

getStatistics

public static StatisticRefCounter getStatistics(java.lang.String name)
                                         throws java.lang.ClassCastException
Create new statistic object with specified name or get the one already existing

Throws:
java.lang.ClassCastException

toString

public java.lang.String toString()
Text representation

Overrides:
toString in class java.lang.Object

changedSinceCheckpoint

public boolean changedSinceCheckpoint()
Reports if value of refCounter has been changed since the last setCheckpoint() call.


setCheckpoint

public void setCheckpoint()
Sets checkpoint. Stores the current state of refCounter.


cast

protected StatisticRefCounter cast()
Description copied from class: Statistics
Returns this statistics as the type provided typed argument. This is a convenience method to avoid unchecked casts.

Specified by:
cast in class Statistics<StatisticRefCounter>
Returns:
this statistics