Package net.sourceforge.pmd.cache
Class AbstractAnalysisCache
- java.lang.Object
-
- net.sourceforge.pmd.cache.AbstractAnalysisCache
-
- All Implemented Interfaces:
AnalysisCache,ThreadSafeReportListener
- Direct Known Subclasses:
FileAnalysisCache
public abstract class AbstractAnalysisCache extends java.lang.Object implements AnalysisCache
Abstract implementation of the analysis cache. Handles all operations, except for persistence.
-
-
Field Summary
Fields Modifier and Type Field Description protected longauxClassPathChecksumprotected longexecutionClassPathChecksumprotected java.util.concurrent.ConcurrentMap<java.lang.String,AnalysisResult>fileResultsCacheprotected static java.util.logging.LoggerLOGprotected java.lang.StringpmdVersionprotected CachedRuleMapperruleMapperprotected longrulesetChecksumprotected java.util.concurrent.ConcurrentMap<java.lang.String,AnalysisResult>updatedResultsCache
-
Constructor Summary
Constructors Constructor Description AbstractAnalysisCache()Creates a new empty cache
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidanalysisFailed(java.io.File sourceFile)Notifies the cache that analysis of the given file has failed and should not be cachedvoidcheckValidity(RuleSets ruleSets, java.lang.ClassLoader auxclassPathClassLoader)Checks if the cache is valid for the configured rulesets and class loader.java.util.List<RuleViolation>getCachedViolations(java.io.File sourceFile)Retrieves cached violations for the given file.booleanisUpToDate(java.io.File sourceFile)Check if a given file is up to date in the cache and can be skipped from analysisvoidmetricAdded(Metric metric)A new metric point has been reported.voidruleViolationAdded(RuleViolation ruleViolation)A new violation has been found.-
Methods inherited from interface net.sourceforge.pmd.cache.AnalysisCache
persist
-
-
-
-
Field Detail
-
LOG
protected static final java.util.logging.Logger LOG
-
pmdVersion
protected final java.lang.String pmdVersion
-
fileResultsCache
protected final java.util.concurrent.ConcurrentMap<java.lang.String,AnalysisResult> fileResultsCache
-
updatedResultsCache
protected final java.util.concurrent.ConcurrentMap<java.lang.String,AnalysisResult> updatedResultsCache
-
rulesetChecksum
protected long rulesetChecksum
-
auxClassPathChecksum
protected long auxClassPathChecksum
-
executionClassPathChecksum
protected long executionClassPathChecksum
-
ruleMapper
protected final CachedRuleMapper ruleMapper
-
-
Method Detail
-
isUpToDate
public boolean isUpToDate(java.io.File sourceFile)
Description copied from interface:AnalysisCacheCheck if a given file is up to date in the cache and can be skipped from analysis- Specified by:
isUpToDatein interfaceAnalysisCache- Parameters:
sourceFile- The file to check in the cache- Returns:
- True if the cache is a hit, false otherwise
-
getCachedViolations
public java.util.List<RuleViolation> getCachedViolations(java.io.File sourceFile)
Description copied from interface:AnalysisCacheRetrieves cached violations for the given file. Make sure to callAnalysisCache.isUpToDate(File)first.- Specified by:
getCachedViolationsin interfaceAnalysisCache- Parameters:
sourceFile- The file to check in the cache- Returns:
- The list of cached violations.
-
analysisFailed
public void analysisFailed(java.io.File sourceFile)
Description copied from interface:AnalysisCacheNotifies the cache that analysis of the given file has failed and should not be cached- Specified by:
analysisFailedin interfaceAnalysisCache- Parameters:
sourceFile- The file whose analysis failed
-
checkValidity
public void checkValidity(RuleSets ruleSets, java.lang.ClassLoader auxclassPathClassLoader)
Description copied from interface:AnalysisCacheChecks if the cache is valid for the configured rulesets and class loader.- Specified by:
checkValidityin interfaceAnalysisCache- Parameters:
ruleSets- The rulesets configured for this analysis.auxclassPathClassLoader- The class loader for auxclasspath configured for this analysis.
-
ruleViolationAdded
public void ruleViolationAdded(RuleViolation ruleViolation)
Description copied from interface:ThreadSafeReportListenerA new violation has been found.- Specified by:
ruleViolationAddedin interfaceThreadSafeReportListener- Parameters:
ruleViolation- the found violation.
-
metricAdded
public void metricAdded(Metric metric)
Description copied from interface:ThreadSafeReportListenerA new metric point has been reported.- Specified by:
metricAddedin interfaceThreadSafeReportListener- Parameters:
metric- the metric
-
-