当前位置: 首页>>代码示例>>Java>>正文


Java AuditEvent.getSourceName方法代码示例

本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.AuditEvent.getSourceName方法的典型用法代码示例。如果您正苦于以下问题:Java AuditEvent.getSourceName方法的具体用法?Java AuditEvent.getSourceName怎么用?Java AuditEvent.getSourceName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.puppycrawl.tools.checkstyle.api.AuditEvent的用法示例。


在下文中一共展示了AuditEvent.getSourceName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:30,代码来源:SuppressWarningsHolder.java

示例2: getCheckShortName

import com.puppycrawl.tools.checkstyle.api.AuditEvent; //导入方法依赖的package包/类
/**
 * Returns check name without 'Check' suffix.
 * @param event audit event.
 * @return check name without 'Check' suffix.
 */
private static String getCheckShortName(AuditEvent event) {
    final String checkFullName = event.getSourceName();
    final String checkShortName;
    final int lastDotIndex = checkFullName.lastIndexOf('.');
    if (lastDotIndex == -1) {
        if (checkFullName.endsWith(SUFFIX)) {
            checkShortName = checkFullName.substring(0, checkFullName.lastIndexOf(SUFFIX));
        }
        else {
            checkShortName = checkFullName.substring(0, checkFullName.length());
        }
    }
    else {
        if (checkFullName.endsWith(SUFFIX)) {
            checkShortName = checkFullName.substring(lastDotIndex + 1,
                checkFullName.lastIndexOf(SUFFIX));
        }
        else {
            checkShortName = checkFullName.substring(lastDotIndex + 1, checkFullName.length());
        }
    }
    return checkShortName;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:29,代码来源:AuditEventDefaultFormatter.java


注:本文中的com.puppycrawl.tools.checkstyle.api.AuditEvent.getSourceName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。