本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.AuditEvent.getModuleId方法的典型用法代码示例。如果您正苦于以下问题:Java AuditEvent.getModuleId方法的具体用法?Java AuditEvent.getModuleId怎么用?Java AuditEvent.getModuleId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.puppycrawl.tools.checkstyle.api.AuditEvent
的用法示例。
在下文中一共展示了AuditEvent.getModuleId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isSuppressed
import com.puppycrawl.tools.checkstyle.api.AuditEvent; //导入方法依赖的package包/类
/**
* Checks for a suppression of a check with the given source name and
* location in the last file processed.
* @param event audit event.
* @return whether the check with the given name is suppressed at the given
* source location
*/
public static boolean isSuppressed(AuditEvent event) {
final List<Entry> entries = ENTRIES.get();
final String sourceName = event.getSourceName();
final String checkAlias = getAlias(sourceName);
final int line = event.getLine();
final int column = event.getColumn();
boolean suppressed = false;
for (Entry entry : entries) {
final boolean afterStart = isSuppressedAfterEventStart(line, column, entry);
final boolean beforeEnd = isSuppressedBeforeEventEnd(line, column, entry);
final boolean nameMatches =
ALL_WARNING_MATCHING_ID.equals(entry.getCheckName())
|| entry.getCheckName().equalsIgnoreCase(checkAlias);
final boolean idMatches = event.getModuleId() != null
&& event.getModuleId().equals(entry.getCheckName());
if (afterStart && beforeEnd && (nameMatches || idMatches)) {
suppressed = true;
break;
}
}
return suppressed;
}
示例2: writeFileError
import com.puppycrawl.tools.checkstyle.api.AuditEvent; //导入方法依赖的package包/类
/**
* Outputs the given event to the writer.
* @param event An event to print.
*/
private void writeFileError(AuditEvent event) {
writer.print("<error" + " line=\"" + event.getLine() + "\"");
if (event.getColumn() > 0) {
writer.print(" column=\"" + event.getColumn() + "\"");
}
writer.print(" severity=\""
+ event.getSeverityLevel().getName()
+ "\"");
writer.print(" message=\""
+ encode(event.getMessage())
+ "\"");
writer.print(" source=\"");
if (event.getModuleId() == null) {
writer.print(encode(event.getSourceName()));
}
else {
writer.print(encode(event.getModuleId()));
}
writer.println("\"/>");
}
示例3: isMatch
import com.puppycrawl.tools.checkstyle.api.AuditEvent; //导入方法依赖的package包/类
/**
* Checks whether the suppression matches the given {@link AuditEvent}.
* @param event {@link AuditEvent} instance.
* @return true if the suppression matches {@link AuditEvent}.
*/
private boolean isMatch(AuditEvent event) {
boolean match = false;
if (isInScopeOfSuppression(event)) {
final Matcher sourceNameMatcher = eventSourceRegexp.matcher(event.getSourceName());
if (sourceNameMatcher.find()) {
match = eventMessageRegexp == null
|| eventMessageRegexp.matcher(event.getMessage()).find();
}
else {
match = event.getModuleId() != null
&& eventSourceRegexp.matcher(event.getModuleId()).find();
}
}
return match;
}
示例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();
}