Package net.sourceforge.pmd.reporting
Class CloseHookFileListener<T extends FileAnalysisListener>
- java.lang.Object
-
- net.sourceforge.pmd.reporting.CloseHookFileListener<T>
-
- Type Parameters:
T- Type of the delegate
- All Implemented Interfaces:
AutoCloseable,FileAnalysisListener
public abstract class CloseHookFileListener<T extends FileAnalysisListener> extends Object implements FileAnalysisListener
A delegating listener wrapper that can override the closing behavior.- Since:
- 7.12.0
-
-
Constructor Summary
Constructors Constructor Description CloseHookFileListener(T delegate)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()Signals the end of the analysis: no further calls will be made to this listener.protected abstract voiddoClose(T delegate, @Nullable Exception e)Perform a close action.voidonError(Report.ProcessingError error)Handle an error that occurred while processing a file.voidonRuleViolation(RuleViolation violation)Handle a new violation (not suppressed).voidonSuppressedRuleViolation(Report.SuppressedViolation violation)Handle a new suppressed violation.StringtoString()
-
-
-
Constructor Detail
-
CloseHookFileListener
public CloseHookFileListener(T delegate)
-
-
Method Detail
-
onRuleViolation
public void onRuleViolation(RuleViolation violation)
Description copied from interface:FileAnalysisListenerHandle a new violation (not suppressed).- Specified by:
onRuleViolationin interfaceFileAnalysisListener
-
onSuppressedRuleViolation
public void onSuppressedRuleViolation(Report.SuppressedViolation violation)
Description copied from interface:FileAnalysisListenerHandle a new suppressed violation.- Specified by:
onSuppressedRuleViolationin interfaceFileAnalysisListener
-
onError
public void onError(Report.ProcessingError error)
Description copied from interface:FileAnalysisListenerHandle an error that occurred while processing a file.- Specified by:
onErrorin interfaceFileAnalysisListener
-
close
public final void close() throws ExceptionDescription copied from interface:FileAnalysisListenerSignals the end of the analysis: no further calls will be made to this listener. This is run in the thread the listener has been used in. This means, if this routine merges some state into some global state of theGlobalAnalysisListener, then that must be synchronized.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceFileAnalysisListener- Throws:
Exception- If an exception occurs, e.g. IOException when writing to a renderer
-
doClose
protected abstract void doClose(T delegate, @Nullable Exception e) throws Exception
Perform a close action. The delegate is given as a parameter, it has already been closed.- Parameters:
delegate- The delegatee- Exception thrown by the delegate when it was closed, or null if it did not throw. The implementation can choose to rethrow that exception or suppress it.- Throws:
Exception
-
-