org.sonar.batch.index
Class DefaultIndex

java.lang.Object
  extended by org.sonar.api.batch.SonarIndex
      extended by org.sonar.batch.index.DefaultIndex
All Implemented Interfaces:
DirectedGraphAccessor<Resource,Dependency>

public class DefaultIndex
extends SonarIndex


Constructor Summary
DefaultIndex(PersistenceManager persistence, DefaultResourceCreationLock lock, ProjectTree projectTree, MetricFinder metricFinder)
           
 
Method Summary
 Dependency addDependency(Dependency dependency)
           
 Event addEvent(Resource resource, String name, String description, String category, Date date)
           
 void addLink(ProjectLink link)
           
 Measure addMeasure(Resource resource, Measure measure)
          the measure is updated if it's already registered.
 Resource addResource(Resource resource)
          Does nothing if the resource is already registered.
 void addViolation(Violation violation, boolean force)
           
 void clear()
          Keep only project stuff
 void deleteEvent(Event event)
           
 void deleteLink(String key)
           
 List<Resource> getChildren(Resource resource)
           
 List<Resource> getChildren(Resource resource, boolean acceptExcluded)
           
 Set<Dependency> getDependencies()
           
 Dependency getEdge(Resource from, Resource to)
           
 List<Event> getEvents(Resource resource)
           
 Collection<Dependency> getIncomingEdges(Resource to)
           
 Measure getMeasure(Resource resource, Metric metric)
           
<M> M
getMeasures(Resource resource, MeasuresFilter<M> filter)
           
 Collection<Dependency> getOutgoingEdges(Resource from)
           
 Resource getParent(Resource resource)
           
 Project getProject()
           
<R extends Resource>
R
getResource(R reference)
          Search for an indexed resource.
 String getSource(Resource resource)
           
 Set<Resource> getVertices()
           
 List<Violation> getViolations(ViolationQuery violationQuery)
          Returns the violations that match the ViolationQuery parameters.
 boolean hasEdge(Resource from, Resource to)
           
 boolean index(Resource resource)
          Indexes a resource as a direct child of project.
 boolean index(Resource resource, Resource parentReference)
          Indexes a resource.
 boolean isExcluded(Resource reference)
          Returns true if the referenced resource is excluded.
 boolean isIndexed(Resource reference, boolean acceptExcluded)
           
 void setCurrentProject(Project project, ResourceFilters resourceFilters, ViolationFilters violationFilters, RulesProfile profile)
           
 void setSource(Resource reference, String source)
          Save the source code of a file.
 void start()
           
 
Methods inherited from class org.sonar.api.batch.SonarIndex
addViolation, getIncomingDependencies, getOutgoingDependencies, getResources, getViolations
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultIndex

public DefaultIndex(PersistenceManager persistence,
                    DefaultResourceCreationLock lock,
                    ProjectTree projectTree,
                    MetricFinder metricFinder)
Method Detail

start

public void start()

getProject

public Project getProject()
Specified by:
getProject in class SonarIndex

setCurrentProject

public void setCurrentProject(Project project,
                              ResourceFilters resourceFilters,
                              ViolationFilters violationFilters,
                              RulesProfile profile)

clear

public void clear()
Keep only project stuff


getMeasure

public Measure getMeasure(Resource resource,
                          Metric metric)
Specified by:
getMeasure in class SonarIndex

getMeasures

public <M> M getMeasures(Resource resource,
                         MeasuresFilter<M> filter)
Specified by:
getMeasures in class SonarIndex

addMeasure

public Measure addMeasure(Resource resource,
                          Measure measure)
the measure is updated if it's already registered.

Specified by:
addMeasure in class SonarIndex

addDependency

public Dependency addDependency(Dependency dependency)
Specified by:
addDependency in class SonarIndex

getDependencies

public Set<Dependency> getDependencies()
Specified by:
getDependencies in class SonarIndex

getEdge

public Dependency getEdge(Resource from,
                          Resource to)

hasEdge

public boolean hasEdge(Resource from,
                       Resource to)

getVertices

public Set<Resource> getVertices()

getOutgoingEdges

public Collection<Dependency> getOutgoingEdges(Resource from)

getIncomingEdges

public Collection<Dependency> getIncomingEdges(Resource to)

getViolations

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

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

addViolation

public void addViolation(Violation violation,
                         boolean force)
Specified by:
addViolation in class SonarIndex

addLink

public void addLink(ProjectLink link)
Specified by:
addLink in class SonarIndex

deleteLink

public void deleteLink(String key)
Specified by:
deleteLink in class SonarIndex

getEvents

public List<Event> getEvents(Resource resource)
Specified by:
getEvents in class SonarIndex

deleteEvent

public void deleteEvent(Event event)
Specified by:
deleteEvent in class SonarIndex

addEvent

public Event addEvent(Resource resource,
                      String name,
                      String description,
                      String category,
                      Date date)
Specified by:
addEvent in class SonarIndex

setSource

public void setSource(Resource reference,
                      String source)
Description copied from class: SonarIndex
Save the source code of a file. The file must be have been indexed before. Note: the source stream is not closed.

Specified by:
setSource in class SonarIndex

getSource

public String getSource(Resource resource)
Specified by:
getSource in class SonarIndex

addResource

public Resource addResource(Resource resource)
Does nothing if the resource is already registered.

Specified by:
addResource in class SonarIndex
Returns:
the indexed resource, even if it's excluded

getResource

public <R extends Resource> R getResource(R reference)
Description copied from class: SonarIndex
Search for an indexed resource.

Specified by:
getResource in class SonarIndex
Parameters:
reference - the resource reference
Returns:
the indexed resource, null if it's not indexed

getChildren

public List<Resource> getChildren(Resource resource)
Specified by:
getChildren in class SonarIndex

getChildren

public List<Resource> getChildren(Resource resource,
                                  boolean acceptExcluded)

getParent

public Resource getParent(Resource resource)
Specified by:
getParent in class SonarIndex

index

public boolean index(Resource resource)
Description copied from class: SonarIndex
Indexes a resource as a direct child of project. This method does nothing and returns true if the resource already indexed. If the method resource.getParent() does not return null, then this parent will be indexed too.

Specified by:
index in class SonarIndex
Returns:
false if the resource is excluded

index

public boolean index(Resource resource,
                     Resource parentReference)
Description copied from class: SonarIndex
Indexes a resource. This method does nothing if the resource is already indexed.

Specified by:
index in class SonarIndex
Parameters:
resource - the resource to index. Not nullable
parentReference - a reference to the indexed parent. If null, the resource is indexed as a direct child of project.
Returns:
false if the parent is not indexed or if the resource is excluded

isExcluded

public boolean isExcluded(Resource reference)
Description copied from class: SonarIndex
Returns true if the referenced resource is excluded. An excluded resource is not indexed.

Specified by:
isExcluded in class SonarIndex

isIndexed

public boolean isIndexed(Resource reference,
                         boolean acceptExcluded)
Specified by:
isIndexed in class SonarIndex


Copyright © 2009-2012 SonarSource. All Rights Reserved.