org.sonar.api.batch
Class TimeMachineQuery

java.lang.Object
  extended by org.sonar.api.batch.TimeMachineQuery

public class TimeMachineQuery
extends Object

A class to query TimeMachine on a given resource

The query is constructed by setting filters on metrics and on dates

It is to be noted that all filters will be applied regardless of their coherence

Since:
1.10

Constructor Summary
TimeMachineQuery(Resource resource)
          Create a TimeMachine query for a given resource
 
Method Summary
 Date getFrom()
           
 List<String> getMetricKeys()
           
 List<Metric> getMetrics()
           
 Resource getResource()
           
 Date getTo()
           
 boolean isFromCurrentAnalysis()
           
 boolean isOnlyLastAnalysis()
           
 boolean isToCurrentAnalysis()
           
 TimeMachineQuery setFrom(Date from)
          Sets the from date to be used in the query
 TimeMachineQuery setFromCurrentAnalysis(boolean b)
           
 TimeMachineQuery setMetricKeys(List<String> metricKeys)
           
 TimeMachineQuery setMetricKeys(String... metricKeys)
           
 TimeMachineQuery setMetrics(List<Metric> metrics)
          Sets the metrics to return
 TimeMachineQuery setMetrics(Metric... metrics)
          Sets the metrics to return
 TimeMachineQuery setOnlyLastAnalysis(boolean onlyLastAnalysis)
           
 TimeMachineQuery setResource(Resource resource)
          Sets the resource of the query
 TimeMachineQuery setTo(Date to)
          Sets the to date to be used in the query
 TimeMachineQuery setToCurrentAnalysis(boolean b)
           
 String toString()
           
 TimeMachineQuery unsetMetrics()
          Unsets the metrics
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TimeMachineQuery

public TimeMachineQuery(Resource resource)

Create a TimeMachine query for a given resource

Apart from the resource the query is empty, i.e. will return all data for the resource

Parameters:
resource - the resource
Method Detail

getResource

public Resource getResource()
Returns:
the resource of the Query

setResource

public TimeMachineQuery setResource(Resource resource)
Sets the resource of the query

Parameters:
resource - the resource
Returns:
this

getMetrics

public List<Metric> getMetrics()
Returns:
the metrics beloging to the query

setMetrics

public TimeMachineQuery setMetrics(List<Metric> metrics)
Sets the metrics to return

Parameters:
metrics - the list of metrics
Returns:
this

setMetricKeys

public TimeMachineQuery setMetricKeys(String... metricKeys)

getMetricKeys

public List<String> getMetricKeys()

setMetricKeys

public TimeMachineQuery setMetricKeys(List<String> metricKeys)

setMetrics

public TimeMachineQuery setMetrics(Metric... metrics)
Sets the metrics to return

Parameters:
metrics - the list of metrics
Returns:
this

unsetMetrics

public TimeMachineQuery unsetMetrics()
Unsets the metrics

Returns:
this

getFrom

public Date getFrom()
Returns:
the from date of the query

setFrom

public TimeMachineQuery setFrom(Date from)
Sets the from date to be used in the query

Parameters:
from - the from date
Returns:
this

setFromCurrentAnalysis

public TimeMachineQuery setFromCurrentAnalysis(boolean b)
Parameters:
b - whether to use the latest analysis as a from date
Returns:
this

setToCurrentAnalysis

public TimeMachineQuery setToCurrentAnalysis(boolean b)
Parameters:
b - whether to use the latest analysis as a to date
Returns:
this

isFromCurrentAnalysis

public boolean isFromCurrentAnalysis()
Returns:
whether the latest analysis is used as a from date

isToCurrentAnalysis

public boolean isToCurrentAnalysis()
Returns:
whether the latest analysis is used as a to date

getTo

public Date getTo()
Returns:
the to date of the query

setTo

public TimeMachineQuery setTo(Date to)
Sets the to date to be used in the query

Parameters:
to - the to date
Returns:
this

isOnlyLastAnalysis

public boolean isOnlyLastAnalysis()
Returns:
whether to return only the latest analysis

setOnlyLastAnalysis

public TimeMachineQuery setOnlyLastAnalysis(boolean onlyLastAnalysis)
Parameters:
onlyLastAnalysis - whether to only return the latest analysis
Returns:
this

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009-2013 SonarSource. All Rights Reserved.