org.sonar.batch
Class DefaultDecoratorContext

java.lang.Object
  extended by org.sonar.batch.DefaultDecoratorContext
All Implemented Interfaces:
DecoratorContext

public class DefaultDecoratorContext
extends Object
implements DecoratorContext


Constructor Summary
DefaultDecoratorContext(Resource resource, SonarIndex index, List<DecoratorContext> childrenContexts)
           
 
Method Summary
 Event createEvent(String name, String description, String category, Date date)
          Creates an event for a given date
 void deleteEvent(Event event)
          Deletes an event
 List<DecoratorContext> getChildren()
          Child contexts are read only
 Collection<Measure> getChildrenMeasures(MeasuresFilter filter)
          Never return null.
 Collection<Measure> getChildrenMeasures(Metric metric)
           
 Set<Dependency> getDependencies()
           
 List<Event> getEvents()
           
 Collection<Dependency> getIncomingDependencies()
           
 Measure getMeasure(Metric metric)
          Find a measure for the resource
<M> M
getMeasures(MeasuresFilter<M> filter)
          Never return null.
 Collection<Dependency> getOutgoingDependencies()
           
 Project getProject()
           
 Resource getResource()
           
 List<Violation> getViolations()
          Returns all the active (= non switched-off) violations found on the current resource.
 List<Violation> getViolations(ViolationQuery violationQuery)
          Returns the violations that match the ViolationQuery parameters.
 Dependency saveDependency(Dependency dependency)
           
 DecoratorContext saveMeasure(Measure measure)
          Add a measure on the current resource.
 DecoratorContext saveMeasure(Metric metric, Double value)
          Add a measure on the current resource.
 DefaultDecoratorContext saveViolation(Violation violation)
          Save a coding rule violation.
 DefaultDecoratorContext saveViolation(Violation violation, boolean force)
          Save a coding rule violation.
 DefaultDecoratorContext setReadOnly(boolean b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDecoratorContext

public DefaultDecoratorContext(Resource resource,
                               SonarIndex index,
                               List<DecoratorContext> childrenContexts)
Method Detail

setReadOnly

public DefaultDecoratorContext setReadOnly(boolean b)

getProject

public Project getProject()
Specified by:
getProject in interface DecoratorContext
Returns:
the project in which the decorator is

getChildren

public List<DecoratorContext> getChildren()
Description copied from interface: DecoratorContext
Child contexts are read only

Specified by:
getChildren in interface DecoratorContext

getMeasures

public <M> M getMeasures(MeasuresFilter<M> filter)
Description copied from interface: DecoratorContext
Never return null.

Specified by:
getMeasures in interface DecoratorContext

getMeasure

public Measure getMeasure(Metric metric)
Description copied from interface: DecoratorContext
Find a measure for the resource

Specified by:
getMeasure in interface DecoratorContext

getChildrenMeasures

public Collection<Measure> getChildrenMeasures(MeasuresFilter filter)
Description copied from interface: DecoratorContext
Never return null.

Specified by:
getChildrenMeasures in interface DecoratorContext

getChildrenMeasures

public Collection<Measure> getChildrenMeasures(Metric metric)
Specified by:
getChildrenMeasures in interface DecoratorContext
Returns:
the resource children measures for the given metric

getResource

public Resource getResource()
Specified by:
getResource in interface DecoratorContext
Returns:
the resource that is currently decorated

saveMeasure

public DecoratorContext saveMeasure(Measure measure)
Description copied from interface: DecoratorContext
Add a measure on the current resource. It can not be executed from children contexts.

Specified by:
saveMeasure in interface DecoratorContext
Returns:
the same context

saveMeasure

public DecoratorContext saveMeasure(Metric metric,
                                    Double value)
Description copied from interface: DecoratorContext
Add a measure on the current resource. It can not be executed from children contexts.

Specified by:
saveMeasure in interface DecoratorContext
Returns:
the current object

getViolations

public List<Violation> getViolations(ViolationQuery violationQuery)
Returns the violations that match the ViolationQuery parameters.

Specified by:
getViolations in interface DecoratorContext
Parameters:
violationQuery - the request parameters specified as a ViolationQuery
Returns:
the list of violations that match those parameters

getViolations

public List<Violation> getViolations()
Returns all the active (= non switched-off) violations found on the current resource.

Specified by:
getViolations in interface DecoratorContext
Returns:
the list of violations

saveDependency

public Dependency saveDependency(Dependency dependency)
Specified by:
saveDependency in interface DecoratorContext

getDependencies

public Set<Dependency> getDependencies()
Specified by:
getDependencies in interface DecoratorContext

getIncomingDependencies

public Collection<Dependency> getIncomingDependencies()
Specified by:
getIncomingDependencies in interface DecoratorContext

getOutgoingDependencies

public Collection<Dependency> getOutgoingDependencies()
Specified by:
getOutgoingDependencies in interface DecoratorContext

getEvents

public List<Event> getEvents()
Specified by:
getEvents in interface DecoratorContext
Returns:
the list of events associated to the current resource

createEvent

public Event createEvent(String name,
                         String description,
                         String category,
                         Date date)
Description copied from interface: DecoratorContext
Creates an event for a given date

Specified by:
createEvent in interface DecoratorContext
Parameters:
name - the event name
description - the event description
category - the event category
date - the event date
Returns:
the created event

deleteEvent

public void deleteEvent(Event event)
Description copied from interface: DecoratorContext
Deletes an event

Specified by:
deleteEvent in interface DecoratorContext
Parameters:
event - the event to delete

saveViolation

public DefaultDecoratorContext saveViolation(Violation violation,
                                             boolean force)
Description copied from interface: DecoratorContext
Save a coding rule violation. The decorator which calls this method must be depended upon BatchBarriers.END_OF_VIOLATIONS_GENERATION.

Specified by:
saveViolation in interface DecoratorContext
force - allows to force creation of violation even if it was suppressed by ViolationFilter

saveViolation

public DefaultDecoratorContext saveViolation(Violation violation)
Description copied from interface: DecoratorContext
Save a coding rule violation. The decorator which calls this method must be depended upon BatchBarriers.END_OF_VIOLATIONS_GENERATION.

Specified by:
saveViolation in interface DecoratorContext


Copyright © 2009-2011 SonarSource. All Rights Reserved.