本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.AuditEvent.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java AuditEvent.getMessage方法的具体用法?Java AuditEvent.getMessage怎么用?Java AuditEvent.getMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.puppycrawl.tools.checkstyle.api.AuditEvent
的用法示例。
在下文中一共展示了AuditEvent.getMessage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: format
import com.puppycrawl.tools.checkstyle.api.AuditEvent; //导入方法依赖的package包/类
@Override
public String format(AuditEvent event) {
final String fileName = event.getFileName();
final String message = event.getMessage();
// avoid StringBuffer.expandCapacity
final int bufLen = event.getFileName().length() + event.getMessage().length()
+ LENGTH_OF_ALL_SEPARATORS;
final StringBuilder sb = new StringBuilder(bufLen);
sb.append(fileName).append(':').append(event.getLine());
if (event.getColumn() > 0) {
sb.append(':').append(event.getColumn());
}
sb.append(": ").append(message);
return sb.toString();
}
示例2: addError
import com.puppycrawl.tools.checkstyle.api.AuditEvent; //导入方法依赖的package包/类
/** @see com.puppycrawl.tools.checkstyle.api.AuditListener */
public void addError(AuditEvent aEvt)
{
final SeverityLevel severityLevel = aEvt.getSeverityLevel();
if (mInitialized && !SeverityLevel.IGNORE.equals(severityLevel)) {
final Log log = mLogFactory.getInstance(aEvt.getSourceName());
final String fileName = aEvt.getFileName();
final String message = aEvt.getMessage();
// avoid StringBuffer.expandCapacity
final int bufLen = message.length() + BUFFER_CUSHION;
final StringBuffer sb = new StringBuffer(bufLen);
sb.append("Line: ").append(aEvt.getLine());
if (aEvt.getColumn() > 0) {
sb.append(" Column: ").append(aEvt.getColumn());
}
sb.append(" Message: ").append(message);
if (aEvt.getSeverityLevel().equals(SeverityLevel.WARNING)) {
log.warn(sb.toString());
}
else if (aEvt.getSeverityLevel().equals(SeverityLevel.INFO)) {
log.info(sb.toString());
}
else {
log.error(sb.toString());
}
}
}
示例3: getMessage
import com.puppycrawl.tools.checkstyle.api.AuditEvent; //导入方法依赖的package包/类
@VisibleForTesting
static String getMessage(AuditEvent event) {
String result;
try {
result = event.getMessage();
}
catch (Exception ex) {
LOG.warn("AuditEvent is created incorrectly. Exception happen during getMessage()", ex);
result = null;
}
return result;
}
示例4: format
import com.puppycrawl.tools.checkstyle.api.AuditEvent; //导入方法依赖的package包/类
@Override
public String format(AuditEvent event) {
final String fileName = event.getFileName();
final String message = event.getMessage();
final SeverityLevel severityLevel = event.getSeverityLevel();
final String severityLevelName;
if (severityLevel == SeverityLevel.WARNING) {
// We change the name of severity level intentionally
// to shorten the length of the log message.
severityLevelName = "WARN";
}
else {
severityLevelName = severityLevel.getName().toUpperCase(Locale.US);
}
// Avoid StringBuffer.expandCapacity
final int bufLen = calculateBufferLength(event, severityLevelName.length());
final StringBuilder sb = new StringBuilder(bufLen);
sb.append('[').append(severityLevelName).append("] ")
.append(fileName).append(':').append(event.getLine());
if (event.getColumn() > 0) {
sb.append(':').append(event.getColumn());
}
sb.append(": ").append(message).append(" [");
if (event.getModuleId() == null) {
final String checkShortName = getCheckShortName(event);
sb.append(checkShortName);
}
else {
sb.append(event.getModuleId());
}
sb.append(']');
return sb.toString();
}
示例5: addError
import com.puppycrawl.tools.checkstyle.api.AuditEvent; //导入方法依赖的package包/类
@Override
public void addError(AuditEvent event) {
final int line = event.getLine();
final String message = event.getMessage();
if (position >= comments.length) {
fail("found a warning when none was expected for #" + position + " at line " + line
+ " with message " + message);
}
final IndentComment comment = comments[position];
position++;
String possibleExceptedMessages = "";
for (String next : comment.getExpectedMessages()) {
possibleExceptedMessages += "\"" + next + "\", ";
}
final String assertMessage = String.format(
Locale.ROOT,
"input expected warning #%d at line %d to report one of the following: %s"
+ "but got instead: %d: %s",
position, comment.getLineNumber(), possibleExceptedMessages, line, message);
boolean anyMatch = false;
for (String s : comment.getExpectedMessages()) {
if (message.endsWith(s)) {
anyMatch = true;
break;
}
}
assertTrue(assertMessage, line == comment.getLineNumber()
&& anyMatch);
}