net.java.dev.moskito.core.stats.impl
Class StatValueImpl

java.lang.Object
  extended by net.java.dev.moskito.core.stats.impl.StatValueImpl
All Implemented Interfaces:
StatValue

 class StatValueImpl
extends Object
implements StatValue

This class implements StatValue.

Author:
dvayanu
See Also:
StatValue, AbstractValueHolder

Field Summary
private static Interval ABSOLUTE_VALUE
          This is the default Interval for the absolute value.
private  ValueHolder absoluteValue
          This attribute holds the absolute value that does not depend on an Interval.
private  IValueHolderFactory factory
          This is the factory instance that is responsible for creation of new ValueHolder instances and will be used mainly on registering new Intervals.
private  String name
          This is the name of statistic value represented by this instance.
private  Map<String,ValueHolder> values
          This map holds all values by the interval name it is responsible for.
private  List<ValueHolder> valuesAsList
          This List contains a redundant copy of the values Map values.
 
Constructor Summary
StatValueImpl(String aName, IValueHolderFactory aFactory)
          This is the contructor.
 
Method Summary
 void addInterval(Interval aInterval)
          This method adds the given Interval.
 void decrease()
          This method decreases the stored values for all Intervals by one.
 void decreaseByDouble(double aValue)
          This method decreases the current values of all registered Intervals by the given double value.
 void decreaseByInt(int aValue)
          This method decreases the current values of all registered Intervals by the given int value.
 void decreaseByLong(long aValue)
          This method decreases the current values of all registered Intervals by the given long value.
private  ValueHolder getHolderByIntervalName(String aIntervalName)
          This method returns the ValueHolder that is stored for the given Interval name.
 String getName()
          This method returns the name of this statistic value.
 double getValueAsDouble()
          This method returns the absolute value as double.
 double getValueAsDouble(String aIntervalName)
          This method returns the current value of a specific Interval as double.
 int getValueAsInt()
          This method returns the absolute value as int.
 int getValueAsInt(String aIntervalName)
          This method returns the current value of a specific Interval as int.
 long getValueAsLong()
          This method returns the absolute value as long.
 long getValueAsLong(String aIntervalName)
          This method returns the current value of a specific Interval as long.
 void increase()
          This method increases the stored values for all Intervals by one.
 void increaseByDouble(double aValue)
          This method increases the current values of all registered Intervals by the given double value.
 void increaseByInt(int aValue)
          This method increases the current values of all registered Intervals by the given int value.
 void increaseByLong(long aValue)
          This method increases the current values of all registered Intervals by the given long value.
 void reset()
          This method resets the ValueHolders of all registered Intervals.
 void setDefaultValueAsDouble(double aValue)
          This method sets the default value that will be the initial value after an Interval was elapsed.
 void setDefaultValueAsInt(int aValue)
          This method sets the default value that will be the initial value after an Interval was elapsed.
 void setDefaultValueAsLong(long aValue)
          This method sets the default value that will be the initial value after an Interval was elapsed.
 void setValueAsDouble(double aValue)
          This method sets the given double value to be the current value of all registered Intervals.
 void setValueAsInt(int aValue)
          This method sets the given int value to be the current value of all registered Intervals.
 void setValueAsLong(long aValue)
          This method sets the given long value to be the current value of all registered Intervals.
 void setValueIfGreaterThanCurrentAsDouble(double aValue)
          This method sets the given double value to be the current value of all registered Intervals depending on the condition "current value < given value".
 void setValueIfGreaterThanCurrentAsInt(int aValue)
          This method sets the given int value to be the current value of all registered Intervals depending on the condition "current value < given value".
 void setValueIfGreaterThanCurrentAsLong(long aValue)
          This method sets the given long value to be the current value of all registered Intervals depending on the condition "current value < given value".
 void setValueIfLesserThanCurrentAsDouble(double aValue)
          This method sets the given double value to be the current value of all registered Intervals depending on the condition "current value > given value".
 void setValueIfLesserThanCurrentAsInt(int aValue)
          This method sets the given int value to be the current value of all registered Intervals depending on the condition "current value > given value".
 void setValueIfLesserThanCurrentAsLong(long aValue)
          This method sets the given long value to be the current value of all registered Intervals depending on the condition "current value > given value".
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ABSOLUTE_VALUE

private static final Interval ABSOLUTE_VALUE
This is the default Interval for the absolute value.


absoluteValue

private ValueHolder absoluteValue
This attribute holds the absolute value that does not depend on an Interval. It will be collected for every instance of this statistic value.


values

private Map<String,ValueHolder> values
This map holds all values by the interval name it is responsible for. So every registered Interval will be represented by an own entry. Besides this Map contains the abolute value.


valuesAsList

private List<ValueHolder> valuesAsList
This List contains a redundant copy of the values Map values. It will be maintained on adding new Intervals.


name

private String name
This is the name of statistic value represented by this instance.


factory

private transient IValueHolderFactory factory
This is the factory instance that is responsible for creation of new ValueHolder instances and will be used mainly on registering new Intervals.

Constructor Detail

StatValueImpl

public StatValueImpl(String aName,
                     IValueHolderFactory aFactory)
This is the contructor.

Parameters:
aName - the name of the statistic value
aFactory - the factory to create ValueHolder instances on Interval registration
Method Detail

addInterval

public void addInterval(Interval aInterval)
Description copied from interface: StatValue
This method adds the given Interval. After every value manipulation will be delegated to this Interval too.

Specified by:
addInterval in interface StatValue
Parameters:
aInterval - the Interval to add
See Also:
StatValue.addInterval(net.java.dev.moskito.core.stats.Interval)

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()

getName

public String getName()
Description copied from interface: StatValue
This method returns the name of this statistic value.

Specified by:
getName in interface StatValue
Returns:
the name
See Also:
StatValue.getName()

increase

public void increase()
Description copied from interface: StatValue
This method increases the stored values for all Intervals by one. Particularly, this includes the absolute value.

Specified by:
increase in interface StatValue
See Also:
StatValue.increase()

decrease

public void decrease()
Description copied from interface: StatValue
This method decreases the stored values for all Intervals by one. Particularly, this includes the absolute value.

Specified by:
decrease in interface StatValue
See Also:
StatValue.decrease()

getHolderByIntervalName

private ValueHolder getHolderByIntervalName(String aIntervalName)
This method returns the ValueHolder that is stored for the given Interval name.

Parameters:
aIntervalName - the name of the interval
Returns:
the stored ValueHolder
Throws:
UnknownIntervalException - if there is no ValueHolder stored for an Interval with the given name

getValueAsInt

public int getValueAsInt()
Description copied from interface: StatValue
This method returns the absolute value as int.

Specified by:
getValueAsInt in interface StatValue
Returns:
the absolute value
See Also:
StatValue.getValueAsInt()

getValueAsLong

public long getValueAsLong()
Description copied from interface: StatValue
This method returns the absolute value as long.

Specified by:
getValueAsLong in interface StatValue
Returns:
the absolute value
See Also:
StatValue.getValueAsLong()

getValueAsDouble

public double getValueAsDouble()
Description copied from interface: StatValue
This method returns the absolute value as double.

Specified by:
getValueAsDouble in interface StatValue
Returns:
the absolute value
See Also:
StatValue.getValueAsDouble()

getValueAsInt

public int getValueAsInt(String aIntervalName)
Description copied from interface: StatValue
This method returns the current value of a specific Interval as int.

Specified by:
getValueAsInt in interface StatValue
Parameters:
aIntervalName - the name of the Interval or null to get the absolute value
Returns:
the current value
See Also:
StatValue.getValueAsInt(java.lang.String)

getValueAsLong

public long getValueAsLong(String aIntervalName)
Description copied from interface: StatValue
This method returns the current value of a specific Interval as long.

Specified by:
getValueAsLong in interface StatValue
Parameters:
aIntervalName - the name of the Interval or null to get the absolute value
Returns:
the current value
See Also:
StatValue.getValueAsLong(java.lang.String)

getValueAsDouble

public double getValueAsDouble(String aIntervalName)
Description copied from interface: StatValue
This method returns the current value of a specific Interval as double.

Specified by:
getValueAsDouble in interface StatValue
Parameters:
aIntervalName - the name of the Interval or null to get the absolute value
Returns:
the current value
See Also:
StatValue.getValueAsDouble(java.lang.String)

setValueAsInt

public void setValueAsInt(int aValue)
Description copied from interface: StatValue
This method sets the given int value to be the current value of all registered Intervals. Particularly, this includes the absolute value.
ATTENTION: The Intervals will not be resetted. So the measured values of the first next Interval cycles are invalid.

Specified by:
setValueAsInt in interface StatValue
Parameters:
aValue - the new value
See Also:
StatValue.setValueAsInt(int)

setValueAsLong

public void setValueAsLong(long aValue)
Description copied from interface: StatValue
This method sets the given long value to be the current value of all registered Intervals. Particularly, this includes the absolute value.
ATTENTION: The Intervals will not be resetted. So the measured values of the first next Interval cycles are invalid.

Specified by:
setValueAsLong in interface StatValue
Parameters:
aValue - the new value
See Also:
StatValue.setValueAsLong(long)

setValueAsDouble

public void setValueAsDouble(double aValue)
Description copied from interface: StatValue
This method sets the given double value to be the current value of all registered Intervals. Particularly, this includes the absolute value.
ATTENTION: The Intervals will not be resetted. So the measured values of the first next Interval cycles are invalid.

Specified by:
setValueAsDouble in interface StatValue
Parameters:
aValue - the new value
See Also:
StatValue.setValueAsDouble(double)

increaseByInt

public void increaseByInt(int aValue)
Description copied from interface: StatValue
This method increases the current values of all registered Intervals by the given int value. Particularly, this includes the absolute value.

Specified by:
increaseByInt in interface StatValue
Parameters:
aValue - the value to increment by
See Also:
StatValue.increaseByInt(int)

increaseByLong

public void increaseByLong(long aValue)
Description copied from interface: StatValue
This method increases the current values of all registered Intervals by the given long value. Particularly, this includes the absolute value.

Specified by:
increaseByLong in interface StatValue
Parameters:
aValue - the value to increment by
See Also:
StatValue.increaseByLong(long)

increaseByDouble

public void increaseByDouble(double aValue)
Description copied from interface: StatValue
This method increases the current values of all registered Intervals by the given double value. Particularly, this includes the absolute value.

Specified by:
increaseByDouble in interface StatValue
Parameters:
aValue - the value to increment by
See Also:
StatValue.increaseByDouble(double)

decreaseByInt

public void decreaseByInt(int aValue)
Description copied from interface: StatValue
This method decreases the current values of all registered Intervals by the given int value. Particularly, this includes the absolute value.

Specified by:
decreaseByInt in interface StatValue
Parameters:
aValue - the value to decrement by
See Also:
StatValue.decreaseByInt(int)

decreaseByLong

public void decreaseByLong(long aValue)
Description copied from interface: StatValue
This method decreases the current values of all registered Intervals by the given long value. Particularly, this includes the absolute value.

Specified by:
decreaseByLong in interface StatValue
Parameters:
aValue - the value to decrement by
See Also:
StatValue.decreaseByLong(long)

decreaseByDouble

public void decreaseByDouble(double aValue)
Description copied from interface: StatValue
This method decreases the current values of all registered Intervals by the given double value. Particularly, this includes the absolute value.

Specified by:
decreaseByDouble in interface StatValue
Parameters:
aValue - the value to decrement by
See Also:
StatValue.decreaseByDouble(double)

setDefaultValueAsLong

public void setDefaultValueAsLong(long aValue)
Description copied from interface: StatValue
This method sets the default value that will be the initial value after an Interval was elapsed. Typically, an Interval implementation will execute "currentValue = defaultValue" after it Interval period was over.

Specified by:
setDefaultValueAsLong in interface StatValue
Parameters:
aValue - the new default value
See Also:
StatValue.setDefaultValueAsLong(long)

setDefaultValueAsInt

public void setDefaultValueAsInt(int aValue)
Description copied from interface: StatValue
This method sets the default value that will be the initial value after an Interval was elapsed. Typically, an Interval implementation will execute "currentValue = defaultValue" after it Interval period was over.

Specified by:
setDefaultValueAsInt in interface StatValue
Parameters:
aValue - the new default value
See Also:
StatValue.setDefaultValueAsInt(int)

setDefaultValueAsDouble

public void setDefaultValueAsDouble(double aValue)
Description copied from interface: StatValue
This method sets the default value that will be the initial value after an Interval was elapsed. Typically, an Interval implementation will execute "currentValue = defaultValue" after it Interval period was over.

Specified by:
setDefaultValueAsDouble in interface StatValue
Parameters:
aValue - the new default value
See Also:
StatValue.setDefaultValueAsDouble(double)

reset

public void reset()
Description copied from interface: StatValue
This method resets the ValueHolders of all registered Intervals. Typically, an Interval implementation will execute "currentValue = defaultValue" on reset.

Specified by:
reset in interface StatValue
See Also:
StatValue.reset()

setValueIfGreaterThanCurrentAsLong

public void setValueIfGreaterThanCurrentAsLong(long aValue)
Description copied from interface: StatValue
This method sets the given long value to be the current value of all registered Intervals depending on the condition "current value < given value". Particularly, this includes the absolute value.
ATTENTION: The Intervals will not be resetted. So the measured values of the first next Interval cycles are invalid.

Specified by:
setValueIfGreaterThanCurrentAsLong in interface StatValue
Parameters:
aValue - the new value
See Also:
StatValue.setValueIfGreaterThanCurrentAsLong(long)

setValueIfGreaterThanCurrentAsInt

public void setValueIfGreaterThanCurrentAsInt(int aValue)
Description copied from interface: StatValue
This method sets the given int value to be the current value of all registered Intervals depending on the condition "current value < given value". Particularly, this includes the absolute value.
ATTENTION: The Intervals will not be resetted. So the measured values of the first next Interval cycles are invalid.

Specified by:
setValueIfGreaterThanCurrentAsInt in interface StatValue
Parameters:
aValue - the new value
See Also:
StatValue.setValueIfGreaterThanCurrentAsInt(int)

setValueIfGreaterThanCurrentAsDouble

public void setValueIfGreaterThanCurrentAsDouble(double aValue)
Description copied from interface: StatValue
This method sets the given double value to be the current value of all registered Intervals depending on the condition "current value < given value". Particularly, this includes the absolute value.
ATTENTION: The Intervals will not be resetted. So the measured values of the first next Interval cycles are invalid.

Specified by:
setValueIfGreaterThanCurrentAsDouble in interface StatValue
Parameters:
aValue - the new value
See Also:
StatValue.setValueIfGreaterThanCurrentAsDouble(double)

setValueIfLesserThanCurrentAsLong

public void setValueIfLesserThanCurrentAsLong(long aValue)
Description copied from interface: StatValue
This method sets the given long value to be the current value of all registered Intervals depending on the condition "current value > given value". Particularly, this includes the absolute value.
ATTENTION: The Intervals will not be resetted. So the measured values of the first next Interval cycles are invalid.

Specified by:
setValueIfLesserThanCurrentAsLong in interface StatValue
Parameters:
aValue - the new value
See Also:
StatValue.setValueIfLesserThanCurrentAsLong(long)

setValueIfLesserThanCurrentAsInt

public void setValueIfLesserThanCurrentAsInt(int aValue)
Description copied from interface: StatValue
This method sets the given int value to be the current value of all registered Intervals depending on the condition "current value > given value". Particularly, this includes the absolute value.
ATTENTION: The Intervals will not be resetted. So the measured values of the first next Interval cycles are invalid.

Specified by:
setValueIfLesserThanCurrentAsInt in interface StatValue
Parameters:
aValue - the new value
See Also:
StatValue.setValueIfLesserThanCurrentAsInt(int)

setValueIfLesserThanCurrentAsDouble

public void setValueIfLesserThanCurrentAsDouble(double aValue)
Description copied from interface: StatValue
This method sets the given double value to be the current value of all registered Intervals depending on the condition "current value > given value". Particularly, this includes the absolute value.
ATTENTION: The Intervals will not be resetted. So the measured values of the first next Interval cycles are invalid.

Specified by:
setValueIfLesserThanCurrentAsDouble in interface StatValue
Parameters:
aValue - the new value
See Also:
StatValue.setValueIfLesserThanCurrentAsDouble(double)


Copyright © 2006 MoSKito Project Team. All Rights Reserved.
MoSKito, the open source java monitoring framework