org.sonar.api.measures
Class Measure

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

public class Measure
extends java.lang.Object

A class to handle measures.

Since:
1.10

Field Summary
protected  Metric.Level alertStatus
           
protected  java.lang.String alertText
           
protected  java.lang.String data
           
protected  java.util.Date date
           
static int DEFAULT_PRECISION
          Default precision when saving a float type metric
protected  java.lang.String description
           
protected  java.lang.Double diff1
           
protected  java.lang.Double diff2
           
protected  java.lang.Double diff3
           
protected static int MAX_TEXT_SIZE
           
protected  Metric metric
           
protected  PersistenceMode persistenceMode
           
protected  java.lang.Integer tendency
           
protected  java.lang.String url
           
protected  java.lang.Double value
           
 
Constructor Summary
Measure()
          Creates an empty measure
Measure(Metric metric)
          Creates a measure with a metric
Measure(Metric metric, java.lang.Double value)
          Creates a measure with a metric and a value
Measure(Metric metric, java.lang.Double value, int precision)
          Creates a measure with a metric, a value and a precision for the value
Measure(Metric metric, java.lang.Double value, java.lang.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, java.lang.String data)
          * Creates a measure with a metric and a data field
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 Metric.Level getAlertStatus()
           
 java.lang.String getAlertText()
           
 java.lang.String getData()
           
 Metric.Level getDataAsLevel()
           
 java.util.Date getDate()
           
 java.lang.String getDescription()
           
 java.lang.Double getDiffValue1()
           
 java.lang.Double getDiffValue2()
           
 java.lang.Double getDiffValue3()
           
 java.lang.Long getId()
           
 java.lang.Integer getIntValue()
           
 Metric getMetric()
           
 PersistenceMode getPersistenceMode()
          Gets the persistence mode of the measure.
 java.lang.Integer getTendency()
          Gets the measure tendency
 java.lang.String getUrl()
           
 java.lang.Double getValue()
           
 int hashCode()
           
 boolean hasOptionalData()
           
 Measure setAlertStatus(Metric.Level status)
          Set the alert status of the measure
 Measure setAlertText(java.lang.String alertText)
          Sets the text associated to the alert on the measure
 Measure setData(Metric.Level level)
          Sets an alert level as the data field
 Measure setData(java.lang.String s)
          Sets the data field of the measure.
 Measure setDate(java.util.Date date)
          Sets the date of the measure - Used only in TimeMachine queries
 Measure setDescription(java.lang.String description)
          Sets the measure description
 Measure setDiffValue1(java.lang.Double diff1)
          Sets the first differential value of the measure
 Measure setDiffValue2(java.lang.Double diff2)
          Sets the second differential value of the measure
 Measure setDiffValue3(java.lang.Double diff3)
          Sets the third differential value of the measure
 Measure setId(java.lang.Long id)
          Sets the measure id - Internal use only
 Measure setIntValue(java.lang.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 setTendency(java.lang.Integer tendency)
          Sets the tendency for the measure
 Measure setUrl(java.lang.String url)
          Sets the URL of the measure
 Measure setValue(java.lang.Double v)
          Sets the measure value with the default precision of 1
 Measure setValue(java.lang.Double v, int precision)
          Sets the measure value with a given precision
 java.lang.String toString()
           
 
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

metric

protected Metric metric

value

protected java.lang.Double value

data

protected java.lang.String data

description

protected java.lang.String description

alertStatus

protected Metric.Level alertStatus

alertText

protected java.lang.String alertText

tendency

protected java.lang.Integer tendency

date

protected java.util.Date date

diff1

protected java.lang.Double diff1

diff2

protected java.lang.Double diff2

diff3

protected java.lang.Double diff3

url

protected java.lang.String url

persistenceMode

protected PersistenceMode persistenceMode
Constructor Detail

Measure

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

Parameters:
metric - the metric

Measure

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

Parameters:
metric - the metric
value - its value

Measure

public Measure(Metric metric,
               java.lang.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,
               java.lang.Double value,
               java.lang.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,
               java.lang.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

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

getDate

public java.util.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(java.util.Date date)
Sets the date of the measure - Used only in TimeMachine queries

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

getValue

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

getIntValue

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

setValue

public Measure setValue(java.lang.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(java.lang.Integer i)
Sets the measure value as an int

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

setValue

public Measure setValue(java.lang.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 java.lang.String getData()
Returns:
the data field of the measure

setData

public Measure setData(java.lang.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

getDescription

public java.lang.String getDescription()
Returns:
the description of the measure

setDescription

public Measure setDescription(java.lang.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 java.lang.String getAlertText()
Returns:
the text associated to the alert on the measure

setAlertText

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

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

getTendency

public java.lang.Integer getTendency()
Gets the measure tendency

Returns:
the tendency

setTendency

public Measure setTendency(java.lang.Integer tendency)
Sets the tendency for the measure

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

getId

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

setId

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

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

getDiffValue1

public java.lang.Double getDiffValue1()
Returns:
the first differential value of the measure

setDiffValue1

public Measure setDiffValue1(java.lang.Double diff1)
Sets the first differential value of the measure

Parameters:
diff1 - the diff
Returns:
the measure object instance

getDiffValue2

public java.lang.Double getDiffValue2()
Returns:
the second differential value of the measure

setDiffValue2

public Measure setDiffValue2(java.lang.Double diff2)
Sets the second differential value of the measure

Parameters:
diff2 - the diff
Returns:
the measure object instance

getDiffValue3

public java.lang.Double getDiffValue3()
Returns:
the third differential value of the measure

setDiffValue3

public Measure setDiffValue3(java.lang.Double diff3)
Sets the third differential value of the measure

Parameters:
diff3 - the diff
Returns:
the measure object instance

getUrl

public java.lang.String getUrl()
Returns:
the url of the measure

setUrl

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

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

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hasOptionalData

public boolean hasOptionalData()


Copyright © 2009-2010 SonarSource. All Rights Reserved.