com.puppycrawl.tools.checkstyle.api

Class AbstractViolationReporter

Implemented Interfaces:
Configurable, Contextualizable
Known Direct Subclasses:
AbstractFileSetCheck, Check

public abstract class AbstractViolationReporter
extends AutomaticBean

Serves as an abstract base class for all modules that report inspection findings. Such modules have a Severity level which is used for the localized messages that are created by the module.

Author:
lkuehne

Method Summary

protected String
getMessageBundle()
Returns the message bundle name resourcebundle that contains the messages used by this module.
String
getSeverity()
Get the severity level's name.
SeverityLevel
getSeverityLevel()
Returns the severity level of the messages generated by this module.
protected void
log(DetailAST aAST, String aKey)
Helper method to log a LocalizedMessage.
protected void
log(DetailAST aAST, String aKey, Object aArg0)
Helper method to log a LocalizedMessage.
protected void
log(DetailAST aAST, String aKey, Object aArg0, Object aArg1)
Helper method to log a LocalizedMessage.
protected void
log(int aLine, String aKey)
Log a message.
protected void
log(int aLineNo, String aKey, Object aArg0)
Helper method to log a LocalizedMessage.
protected void
log(int aLineNo, String aKey, Object aArg0, Object aArg1)
Helper method to log a LocalizedMessage.
protected void
log(int aLine, String aKey, aArgs[] )
Log a message that has no column information.
protected void
log(int aLineNo, int aColNo, String aKey)
Helper method to log a LocalizedMessage.
protected void
log(int aLineNo, int aColNo, String aKey, Object aArg0)
Helper method to log a LocalizedMessage.
protected void
log(int aLineNo, int aColNo, String aKey, Object aArg0, Object aArg1)
Helper method to log a LocalizedMessage.
protected void
log(int aLine, int aCol, String aKey, Object[] aArgs)
Log a message that has column information.
void
setSeverity(String aSeverity)
Sets the severity level.

Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean

configure, contextualize, finishLocalSetup, getConfiguration, setupChild

Method Details

getMessageBundle

protected String getMessageBundle()
Returns the message bundle name resourcebundle that contains the messages used by this module.

The default implementation expects the resource files to be named messages.properties, messages_de.properties, etc. The file must be placed in the same package as the module implementation.

Example: If you write com/foo/MyCoolCheck, create resource files com/foo/messages.properties, com/foo/messages_de.properties, etc.

Returns:
name of a resource bundle that contains the messages used by this module.


getSeverity

public final String getSeverity()
Get the severity level's name.

Returns:
the check's severity level name.


getSeverityLevel

public final SeverityLevel getSeverityLevel()
Returns the severity level of the messages generated by this module.

Returns:
the severity level

See Also:
SeverityLevel, LocalizedMessage.getSeverityLevel()


log

protected final void log(DetailAST aAST,
                         String aKey)
Helper method to log a LocalizedMessage.

Parameters:
aAST - a node to get line and column numbers associated with the message
aKey - key to locale message format


log

protected final void log(DetailAST aAST,
                         String aKey,
                         Object aArg0)
Helper method to log a LocalizedMessage.

Parameters:
aAST - a node to get line and column numbers associated with the message
aKey - key to locale message format
aArg0 - an Object value


log

protected final void log(DetailAST aAST,
                         String aKey,
                         Object aArg0,
                         Object aArg1)
Helper method to log a LocalizedMessage.

Parameters:
aAST - a node to get line and column numbers associated with the message
aKey - key to locale message format
aArg0 - an Object value
aArg1 - an Object value


log

protected final void log(int aLine,
                         String aKey)
Log a message.

Parameters:
aLine - the line number where the error was found
aKey - the message that describes the error


log

protected final void log(int aLineNo,
                         String aKey,
                         Object aArg0)
Helper method to log a LocalizedMessage. Column defaults to 0.

Parameters:
aLineNo - line number to associate with the message
aKey - key to locale message format
aArg0 - first argument


log

protected final void log(int aLineNo,
                         String aKey,
                         Object aArg0,
                         Object aArg1)
Helper method to log a LocalizedMessage. Column defaults to 0.

Parameters:
aLineNo - line number to associate with the message
aKey - key to locale message format
aArg0 - first argument
aArg1 - second argument


log

protected void log(int aLine,
                   String aKey,
                   aArgs[] )
Log a message that has no column information.

Parameters:
aLine - the line number where the error was found
aKey - the message that describes the error

See Also:
java.text.MessageFormat


log

protected final void log(int aLineNo,
                         int aColNo,
                         String aKey)
Helper method to log a LocalizedMessage.

Parameters:
aLineNo - line number to associate with the message
aColNo - column number to associate with the message
aKey - key to locale message format


log

protected final void log(int aLineNo,
                         int aColNo,
                         String aKey,
                         Object aArg0)
Helper method to log a LocalizedMessage.

Parameters:
aLineNo - line number to associate with the message
aColNo - column number to associate with the message
aKey - key to locale message format
aArg0 - an Object value


log

protected final void log(int aLineNo,
                         int aColNo,
                         String aKey,
                         Object aArg0,
                         Object aArg1)
Helper method to log a LocalizedMessage.

Parameters:
aLineNo - line number to associate with the message
aColNo - column number to associate with the message
aKey - key to locale message format
aArg0 - an Object value
aArg1 - an Object value


log

protected void log(int aLine,
                   int aCol,
                   String aKey,
                   Object[] aArgs)
Log a message that has column information.

Parameters:
aLine - the line number where the error was found
aCol - the column number where the error was found
aKey - the message that describes the error
aArgs - the details of the message

See Also:
java.text.MessageFormat


setSeverity

public final void setSeverity(String aSeverity)
Sets the severity level. The string should be one of the names defined in the SeverityLevel class.

Parameters:
aSeverity - The new severity level

See Also:
SeverityLevel