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


Java SeverityLevel.WARNING属性代码示例

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


在下文中一共展示了SeverityLevel.WARNING属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: realExecute

/**
 * Helper implementation to perform execution.
 * @param checkstyleVersion Checkstyle compile version.
 */
private void realExecute(String checkstyleVersion) {
    // Create the root module
    RootModule rootModule = null;
    try {
        rootModule = createRootModule();

        // setup the listeners
        final AuditListener[] listeners = getListeners();
        for (AuditListener element : listeners) {
            rootModule.addListener(element);
        }
        final SeverityLevelCounter warningCounter =
            new SeverityLevelCounter(SeverityLevel.WARNING);
        rootModule.addListener(warningCounter);

        processFiles(rootModule, warningCounter, checkstyleVersion);
    }
    finally {
        destroyRootModule(rootModule);
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:25,代码来源:CheckstyleAntTask.java

示例2: format

@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();
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:37,代码来源:AuditEventDefaultFormatter.java

示例3: testFormatFullyQualifiedModuleNameContainsCheckSuffix

@Test
public void testFormatFullyQualifiedModuleNameContainsCheckSuffix() {
    final LocalizedMessage message = new LocalizedMessage(1, 1, null, null, null,
            SeverityLevel.WARNING, null, TestModuleCheck.class, "Mocked message.");
    final AuditEvent event = new AuditEvent("", "InputMockFile.java", message);
    final AuditEventFormatter formatter = new AuditEventDefaultFormatter();

    final String expected = "[WARN] InputMockFile.java:1:1: Mocked message. "
            + "[AuditEventDefaultFormatterTest$TestModule]";

    assertEquals("Invalid format", expected, formatter.format(event));
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:12,代码来源:AuditEventDefaultFormatterTest.java

示例4: testFormatFullyQualifiedModuleNameDoesNotContainCheckSuffix

@Test
public void testFormatFullyQualifiedModuleNameDoesNotContainCheckSuffix() {
    final LocalizedMessage message = new LocalizedMessage(1, 1, null, null, null,
            SeverityLevel.WARNING, null, TestModule.class, "Mocked message.");
    final AuditEvent event = new AuditEvent("", "InputMockFile.java", message);
    final AuditEventFormatter formatter = new AuditEventDefaultFormatter();

    final String expected = "[WARN] InputMockFile.java:1:1: Mocked message. "
            + "[AuditEventDefaultFormatterTest$TestModule]";

    assertEquals("Invalid format", expected, formatter.format(event));
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:12,代码来源:AuditEventDefaultFormatterTest.java

示例5: testFormatModuleWithModuleId

@Test
public void testFormatModuleWithModuleId() {
    final LocalizedMessage message = new LocalizedMessage(1, 1, null, null, null,
            SeverityLevel.WARNING, "ModuleId", TestModule.class, "Mocked message.");
    final AuditEvent event = new AuditEvent("", "InputMockFile.java", message);
    final AuditEventFormatter formatter = new AuditEventDefaultFormatter();

    final String expected = "[WARN] InputMockFile.java:1:1: Mocked message. [ModuleId]";

    assertEquals("Invalid format", expected, formatter.format(event));
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:11,代码来源:AuditEventDefaultFormatterTest.java


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