org.sonar.api.measures
Class Measure

java.lang.Object
  extended by org.sonar.api.measures.Measure
Direct Known Subclasses:
RuleMeasure

public class Measure
extends Object

A class to handle measures.

Since:
1.10

Field Summary
protected  Metric.Level alertStatus
           
protected  String alertText
           
protected  Characteristic characteristic
           
protected  String data
           
protected  Date date
           
static int DEFAULT_PRECISION
          Default precision when saving a float type metric
protected  String description
           
protected static int MAX_TEXT_SIZE
           
protected  Metric metric
           
protected  String metricKey
           
protected  PersistenceMode persistenceMode
           
protected  Integer personId
           
protected  Integer tendency
           
protected  String url
           
protected  Double value
           
protected  Double variation1
           
protected  Double variation2
           
protected  Double variation3
           
protected  Double variation4
           
protected  Double variation5
           
 
Constructor Summary
Measure()
          Creates an empty measure
Measure(Metric metric)
          Creates a measure with a metric
Measure(Metric metric, Double value)
          Creates a measure with a metric and a value
Measure(Metric metric, Double value, int precision)
          Creates a measure with a metric, a value and a precision for the value
Measure(Metric metric, Double value, String data)
          Creates a measure with a metric, a value and a data field
Measure(Metric metric, Metric.Level level)
          Creates a measure with a metric and an alert level
Measure(Metric metric, String data)
          * Creates a measure with a metric and a data field
Measure(String metricKey)
           
 
Method Summary
 boolean equals(Object o)
           
 Metric.Level getAlertStatus()
           
 String getAlertText()
           
 Characteristic getCharacteristic()
           
 String getData()
           
 Metric.Level getDataAsLevel()
           
 Date getDate()
           
 String getDescription()
           
 Long getId()
           
 Integer getIntValue()
           
 Metric getMetric()
           
 String getMetricKey()
           
 PersistenceMode getPersistenceMode()
          Gets the persistence mode of the measure.
 Integer getPersonId()
           
 Integer getTendency()
          Gets the measure tendency
 String getUrl()
           
 Double getValue()
           
 Double getVariation(int index)
           
 Double getVariation1()
           
 Double getVariation2()
           
 Double getVariation3()
           
 Double getVariation4()
           
 Double getVariation5()
           
 boolean hasData()
           
 int hashCode()
           
 Measure setAlertStatus(Metric.Level status)
          Set the alert status of the measure
 Measure setAlertText(String alertText)
          Sets the text associated to the alert on the measure
 Measure setCharacteristic(Characteristic characteristic)
           
 Measure setData(Metric.Level level)
          Sets an alert level as the data field
 Measure setData(String s)
          Sets the data field of the measure.
 Measure setDate(Date date)
          Sets the date of the measure - Used only in TimeMachine queries
 Measure setDescription(String description)
          Sets the measure description
 Measure setId(Long id)
          Sets the measure id - Internal use only
 Measure setIntValue(Integer i)
          Sets the measure value as an int
 Measure setMetric(Metric metric)
          Set the underlying metric
 Measure setPersistenceMode(PersistenceMode mode)
           Sets the persistence mode of a measure.
 Measure setPersonId(Integer i)
           
 Measure setTendency(Integer tendency)
          Sets the tendency for the measure - Internal use only
 Measure setUrl(String url)
          Sets the URL of the measure
 Measure setValue(Double v)
          Sets the measure value with the default precision of 1
 Measure setValue(Double v, int precision)
          Sets the measure value with a given precision
 Measure setVariation(int index, Double d)
          Internal use only
 Measure setVariation1(Double d)
          Internal use only
 Measure setVariation2(Double d)
          Internal use only
 Measure setVariation3(Double d)
          Internal use only
 Measure setVariation4(Double d)
          Internal use only
 Measure setVariation5(Double d)
          Internal use only
 String toString()
           
 Measure unsetData()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_TEXT_SIZE

protected static final int MAX_TEXT_SIZE
See Also:
Constant Field Values

DEFAULT_PRECISION

public static final int DEFAULT_PRECISION
Default precision when saving a float type metric

See Also:
Constant Field Values

metricKey

protected String metricKey

metric

protected Metric metric

value

protected Double value

data

protected String data

description

protected String description

alertStatus

protected Metric.Level alertStatus

alertText

protected String alertText

tendency

protected Integer tendency

date

protected Date date

variation1

protected Double variation1

variation2

protected Double variation2

variation3

protected Double variation3

variation4

protected Double variation4

variation5

protected Double variation5

url

protected String url

characteristic

protected Characteristic characteristic

personId

protected Integer personId

persistenceMode

protected PersistenceMode persistenceMode
Constructor Detail

Measure

public Measure(String metricKey)

Measure

public Measure(Metric metric)
Creates a measure with a metric

Parameters:
metric - the metric

Measure

public Measure(Metric metric,
               Double value)
Creates a measure with a metric and a value

Parameters:
metric - the metric
value - its value

Measure

public Measure(Metric metric,
               Double value,
               int precision)
Creates a measure with a metric, a value and a precision for the value

Parameters:
metric - the metric
value - its value
precision - the value precision

Measure

public Measure(Metric metric,
               Double value,
               String data)
Creates a measure with a metric, a value and a data field

Parameters:
metric - the metric
value - the value
data - the data field

Measure

public Measure(Metric metric,
               String data)
* Creates a measure with a metric and a data field

Parameters:
metric - the metric
data - the data field

Measure

public Measure(Metric metric,
               Metric.Level level)
Creates a measure with a metric and an alert level

Parameters:
metric - the metric
level - the alert level

Measure

public Measure()
Creates an empty measure

Method Detail

getPersistenceMode

public PersistenceMode getPersistenceMode()
Gets the persistence mode of the measure. Default persistence mode is FULL, except when instantiating the measure with a String parameter.


setPersistenceMode

public Measure setPersistenceMode(PersistenceMode mode)

Sets the persistence mode of a measure.

WARNING : Being able to reuse measures saved in memory is only possible within the same tree. In a multi-module project for example, a measure save in memory at the module level will not be accessible by the root project. In that case, database should be used.

Parameters:
mode - the mode
Returns:
the measure object instance

getMetric

public Metric getMetric()
Returns:
return the measures underlying metric

getMetricKey

public String getMetricKey()

setMetric

public Measure setMetric(Metric metric)
Set the underlying metric

Parameters:
metric - the metric
Returns:
the measure object instance

getDataAsLevel

public Metric.Level getDataAsLevel()
Returns:
transforms and returns the data fields as a level of alert

hasData

public boolean hasData()

getDate

public Date getDate()
Returns:
the date of the measure, i.e. the date the measure was taken. Used only in TimeMachine queries

setDate

public Measure setDate(Date date)
Sets the date of the measure - Used only in TimeMachine queries

Parameters:
date - the date
Returns:
the measure object instance

getValue

public Double getValue()
Returns:
the value of the measure as a double

getIntValue

public Integer getIntValue()
Returns:
the value of the measure as an int

setValue

public Measure setValue(Double v)
Sets the measure value with the default precision of 1

Parameters:
v - the measure value
Returns:
the measure object instance

setIntValue

public Measure setIntValue(Integer i)
Sets the measure value as an int

Parameters:
i - the value
Returns:
the measure object instance

setValue

public Measure setValue(Double v,
                        int precision)
Sets the measure value with a given precision

Parameters:
v - the measure value
precision - the measure value precision
Returns:
the measure object instance

getData

public String getData()
Returns:
the data field of the measure

setData

public Measure setData(String s)
Sets the data field of the measure.

Parameters:
s - the data
Returns:
the measure object instance

setData

public Measure setData(Metric.Level level)
Sets an alert level as the data field

Parameters:
level - the alert level
Returns:
the measure object instance

unsetData

public Measure unsetData()
Since:
2.7

getDescription

public String getDescription()
Returns:
the description of the measure

setDescription

public Measure setDescription(String description)
Sets the measure description

Parameters:
description - the description
Returns:
the measure object instance

getAlertStatus

public Metric.Level getAlertStatus()
Returns:
the alert status of the measure

setAlertStatus

public Measure setAlertStatus(Metric.Level status)
Set the alert status of the measure

Parameters:
status - the status
Returns:
the measure object instance

getAlertText

public String getAlertText()
Returns:
the text associated to the alert on the measure

setAlertText

public Measure setAlertText(String alertText)
Sets the text associated to the alert on the measure

Parameters:
alertText - the text
Returns:
the measure object instance

getTendency

public Integer getTendency()
Gets the measure tendency

Returns:
the tendency

setTendency

public Measure setTendency(Integer tendency)
Sets the tendency for the measure - Internal use only

Parameters:
tendency - the tendency
Returns:
the measure object instance

getId

public Long getId()
Returns:
the measure id - Internal use only

setId

public Measure setId(Long id)
Sets the measure id - Internal use only

Parameters:
id - the id
Returns:
the measure object instance

getVariation1

public Double getVariation1()
Returns:
the first variation value
Since:
2.5

setVariation1

public Measure setVariation1(Double d)
Internal use only

Since:
2.5

getVariation2

public Double getVariation2()
Returns:
the second variation value
Since:
2.5

setVariation2

public Measure setVariation2(Double d)
Internal use only

Since:
2.5

getVariation3

public Double getVariation3()
Returns:
the third variation value
Since:
2.5

setVariation3

public Measure setVariation3(Double d)
Internal use only

Since:
2.5

getVariation4

public Double getVariation4()
Returns:
the third variation value
Since:
2.5

setVariation4

public Measure setVariation4(Double d)
Internal use only

Since:
2.5

getVariation5

public Double getVariation5()
Returns:
the third variation value
Since:
2.5

setVariation5

public Measure setVariation5(Double d)
Internal use only

Since:
2.5

getVariation

public Double getVariation(int index)
Since:
2.5

setVariation

public Measure setVariation(int index,
                            Double d)
Internal use only

Since:
2.5

getUrl

public String getUrl()
Returns:
the url of the measure

setUrl

public Measure setUrl(String url)
Sets the URL of the measure

Parameters:
url - the url
Returns:
the measure object instance

getCharacteristic

public final Characteristic getCharacteristic()
Since:
2.3

setCharacteristic

public final Measure setCharacteristic(Characteristic characteristic)
Since:
2.3

getPersonId

@Beta
public Integer getPersonId()
Since:
2.14

setPersonId

@Beta
public Measure setPersonId(Integer i)
Since:
2.14

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009-2012 SonarSource. All Rights Reserved.