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


Java MessageDispatcher类代码示例

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


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

示例1: checkFilesForConsistencyRegardingTheirKeys

import com.puppycrawl.tools.checkstyle.api.MessageDispatcher; //导入依赖的package包/类
/**
 * Compares th the specified key set with the key sets of the given translation files (arranged
 * in a map). All missing keys are reported.
 * @param fileKeys a Map from translation files to their key sets.
 * @param keysThatMustExist the set of keys to compare with.
 */
private void checkFilesForConsistencyRegardingTheirKeys(SetMultimap<File, String> fileKeys,
                                                        Set<String> keysThatMustExist) {
    for (File currentFile : fileKeys.keySet()) {
        final MessageDispatcher dispatcher = getMessageDispatcher();
        final String path = currentFile.getPath();
        dispatcher.fireFileStarted(path);
        final Set<String> currentFileKeys = fileKeys.get(currentFile);
        final Set<String> missingKeys = new HashSet<String>();
        for (String e : keysThatMustExist) {
            if (!currentFileKeys.contains(e)) {
                missingKeys.add(e);
            }
        }
        if (!missingKeys.isEmpty()) {
            for (Object key : missingKeys) {
                log(0, MSG_KEY, key);
            }
        }
        fireErrors(path);
        dispatcher.fireFileFinished(path);
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:29,代码来源:TranslationCheck.java

示例2: testLogIoException

import com.puppycrawl.tools.checkstyle.api.MessageDispatcher; //导入依赖的package包/类
@Test
public void testLogIoException() throws Exception {
    //I can't put wrong file here. Checkstyle fails before check started.
    //I saw some usage of file or handling of wrong file in Checker, or somewhere
    //in checks running part. So I had to do it with reflection to improve coverage.
    final TranslationCheck check = new TranslationCheck();
    final DefaultConfiguration checkConfig = createModuleConfig(TranslationCheck.class);
    final MessageDispatcher dispatcher = mock(MessageDispatcher.class);
    check.configure(checkConfig);
    check.setMessageDispatcher(dispatcher);

    final Method logIoException = check.getClass().getDeclaredMethod("logIoException",
            IOException.class,
            File.class);
    logIoException.setAccessible(true);
    final File file = new File("");
    logIoException.invoke(check, new IOException("test exception"), file);

    Mockito.verify(dispatcher, times(1)).fireErrors(any(String.class), captor.capture());
    final String actual = captor.getValue().first().getMessage();
    assertThat("Invalid message: " + actual, actual, endsWith("test exception"));
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:23,代码来源:TranslationCheckTest.java

示例3: checkFilesForConsistencyRegardingTheirKeys

import com.puppycrawl.tools.checkstyle.api.MessageDispatcher; //导入依赖的package包/类
/**
 * Compares th the specified key set with the key sets of the given translation files (arranged
 * in a map). All missing keys are reported.
 * @param fileKeys a Map from translation files to their key sets.
 * @param keysThatMustExist the set of keys to compare with.
 */
private void checkFilesForConsistencyRegardingTheirKeys(SetMultimap<File, String> fileKeys,
                                                        Set<String> keysThatMustExist) {
    for (File currentFile : fileKeys.keySet()) {
        final MessageDispatcher dispatcher = getMessageDispatcher();
        final String path = currentFile.getPath();
        dispatcher.fireFileStarted(path);
        final Set<String> currentFileKeys = fileKeys.get(currentFile);
        final Set<String> missingKeys = keysThatMustExist.stream()
            .filter(e -> !currentFileKeys.contains(e)).collect(Collectors.toSet());
        if (!missingKeys.isEmpty()) {
            for (Object key : missingKeys) {
                log(0, MSG_KEY, key);
            }
        }
        fireErrors(path);
        dispatcher.fireFileFinished(path);
    }
}
 
开发者ID:checkstyle,项目名称:checkstyle,代码行数:25,代码来源:TranslationCheck.java

示例4: logMissingTranslation

import com.puppycrawl.tools.checkstyle.api.MessageDispatcher; //导入依赖的package包/类
/**
 * Logs that translation file is missing.
 * @param filePath file path.
 * @param fileName file name.
 */
private void logMissingTranslation(String filePath, String fileName) {
    final MessageDispatcher dispatcher = getMessageDispatcher();
    dispatcher.fireFileStarted(filePath);
    log(0, MSG_KEY_MISSING_TRANSLATION_FILE, fileName);
    fireErrors(filePath);
    dispatcher.fireFileFinished(filePath);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:13,代码来源:TranslationCheck.java

示例5: getInternalMessageDispatcher

import com.puppycrawl.tools.checkstyle.api.MessageDispatcher; //导入依赖的package包/类
public MessageDispatcher getInternalMessageDispatcher() {
    return getMessageDispatcher();
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:4,代码来源:CheckerTest.java

示例6: setMessageDispatcher

import com.puppycrawl.tools.checkstyle.api.MessageDispatcher; //导入依赖的package包/类
public void setMessageDispatcher(MessageDispatcher dispatcher) {
    check.setMessageDispatcher(dispatcher);
}
 
开发者ID:willfleury,项目名称:netbeans-checkstyle,代码行数:4,代码来源:CancellableChecker.java


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