org.sonar.api.measures
Class RangeDistributionBuilder

java.lang.Object
  extended by org.sonar.api.measures.RangeDistributionBuilder
All Implemented Interfaces:
MeasureBuilder

public class RangeDistributionBuilder
extends java.lang.Object
implements MeasureBuilder

Utility to build a distribution based on defined ranges

An example of usage : you wish to record the percentage of lines of code that belong to method with pre-defined ranges of complexity.

Since:
1.10

Constructor Summary
RangeDistributionBuilder(Metric metric, java.lang.Number[] bottomLimits)
          RangeDistributionBuilder for a metric and a defined range Each entry is initialize at zero
 
Method Summary
 RangeDistributionBuilder add(Measure measure)
          Adds an existing Distribution to the current one.
 RangeDistributionBuilder add(java.lang.Number value)
          Increments an entry by 1
 RangeDistributionBuilder add(java.lang.Number value, int count)
          Increments an entry
 Measure build()
          Shortcut for build(true)
 Measure build(boolean allowEmptyData)
          Used to build a measure from the current object
 RangeDistributionBuilder clear()
          Resets all entries to zero
 java.lang.Number[] getBottomLimits()
          Gives the bottom limits of ranges used
 boolean isEmpty()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RangeDistributionBuilder

public RangeDistributionBuilder(Metric metric,
                                java.lang.Number[] bottomLimits)
RangeDistributionBuilder for a metric and a defined range Each entry is initialize at zero

Parameters:
metric - the metric to record the measure against
bottomLimits - the bottom limits of ranges to be used
Method Detail

getBottomLimits

public java.lang.Number[] getBottomLimits()
Gives the bottom limits of ranges used

Returns:
the bottom limits of defined range for the distribution

add

public RangeDistributionBuilder add(java.lang.Number value)
Increments an entry by 1

Parameters:
value - the value to use to pick the entry to increment
Returns:
the current object

add

public RangeDistributionBuilder add(java.lang.Number value,
                                    int count)
Increments an entry

Parameters:
value - the value to use to pick the entry to increment
count - the number by which to increment
Returns:
the current object

add

public RangeDistributionBuilder add(Measure measure)
Adds an existing Distribution to the current one. It will create the entries if they don't exist. Can be used to add the values of children resources for example

Parameters:
measure - the measure to add to the current one
Returns:
the current object

clear

public RangeDistributionBuilder clear()
Resets all entries to zero

Returns:
the current object

isEmpty

public boolean isEmpty()
Returns:
whether the current object is empty or not

build

public Measure build()
Shortcut for build(true)

Specified by:
build in interface MeasureBuilder
Returns:
the built measure

build

public Measure build(boolean allowEmptyData)
Used to build a measure from the current object

Parameters:
allowEmptyData - should be built if current object is empty
Returns:
the built measure


Copyright © 2009-2010 SonarSource SA. All Rights Reserved.