• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AutomaticBean类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getListeners

import com.puppycrawl.tools.checkstyle.api.AutomaticBean; //导入依赖的package包/类
/**
 * Return the list of listeners set in this task.
 * @return the list of listeners.
 */
private AuditListener[] getListeners() {
    final int formatterCount = Math.max(1, formatters.size());

    final AuditListener[] listeners = new AuditListener[formatterCount];

    // formatters
    try {
        if (formatters.isEmpty()) {
            final OutputStream debug = new LogOutputStream(this, Project.MSG_DEBUG);
            final OutputStream err = new LogOutputStream(this, Project.MSG_ERR);
            listeners[0] = new DefaultLogger(debug, AutomaticBean.OutputStreamOptions.CLOSE,
                    err, AutomaticBean.OutputStreamOptions.CLOSE);
        }
        else {
            for (int i = 0; i < formatterCount; i++) {
                final Formatter formatter = formatters.get(i);
                listeners[i] = formatter.createListener(this);
            }
        }
    }
    catch (IOException ex) {
        throw new BuildException(String.format(Locale.ROOT, "Unable to create listeners: "
                + "formatters {%s}.", formatters), ex);
    }
    return listeners;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:31,代码来源:CheckstyleAntTask.java


示例2: setupChild

import com.puppycrawl.tools.checkstyle.api.AutomaticBean; //导入依赖的package包/类
/**
 * {@inheritDoc} Creates child module.
 * @noinspection ChainOfInstanceofChecks
 */
@Override
public void setupChild(Configuration childConf)
        throws CheckstyleException {
    final String name = childConf.getName();
    final Object module = moduleFactory.createModule(name);
    if (module instanceof AutomaticBean) {
        final AutomaticBean bean = (AutomaticBean) module;
        bean.contextualize(childContext);
        bean.configure(childConf);
    }
    if (module instanceof AbstractCheck) {
        final AbstractCheck check = (AbstractCheck) module;
        check.init();
        registerCheck(check);
    }
    else if (module instanceof TreeWalkerFilter) {
        final TreeWalkerFilter filter = (TreeWalkerFilter) module;
        filters.add(filter);
    }
    else {
        throw new CheckstyleException(
            "TreeWalker is not allowed as a parent of " + name
                    + " Please review 'Parent Module' section for this Check in web"
                    + " documentation if Check is standard.");
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:31,代码来源:TreeWalker.java


示例3: testCloseStream

import com.puppycrawl.tools.checkstyle.api.AutomaticBean; //导入依赖的package包/类
@Test
public void testCloseStream()
        throws Exception {
    final XMLLogger logger = new XMLLogger(outStream,
            AutomaticBean.OutputStreamOptions.CLOSE);
    logger.auditStarted(null);
    logger.auditFinished(null);

    assertEquals("Invalid close count", 1, outStream.getCloseCount());

    verifyXml(getPath("ExpectedXMLLoggerEmpty.xml"), outStream);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:13,代码来源:XMLLoggerTest.java


示例4: testNoCloseStream

import com.puppycrawl.tools.checkstyle.api.AutomaticBean; //导入依赖的package包/类
@Test
public void testNoCloseStream()
        throws Exception {
    final XMLLogger logger = new XMLLogger(outStream,
            AutomaticBean.OutputStreamOptions.NONE);
    logger.auditStarted(null);
    logger.auditFinished(null);

    assertEquals("Invalid close count", 0, outStream.getCloseCount());

    outStream.close();
    verifyXml(getPath("ExpectedXMLLoggerEmpty.xml"), outStream);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:14,代码来源:XMLLoggerTest.java


示例5: testNewCtor

import com.puppycrawl.tools.checkstyle.api.AutomaticBean; //导入依赖的package包/类
@Test
public void testNewCtor() throws Exception {
    final OutputStream infoStream = spy(new ByteArrayOutputStream());
    final ByteArrayOutputStream errorStream = spy(new ByteArrayOutputStream());
    final DefaultLogger dl = new DefaultLogger(infoStream,
            AutomaticBean.OutputStreamOptions.CLOSE, errorStream,
            AutomaticBean.OutputStreamOptions.CLOSE);
    dl.auditStarted(null);
    dl.addException(new AuditEvent(5000, "myfile"), new IllegalStateException("upsss"));
    dl.auditFinished(new AuditEvent(6000, "myfile"));
    final String output = errorStream.toString(StandardCharsets.UTF_8.name());
    final LocalizedMessage addExceptionMessage = new LocalizedMessage(0,
            Definitions.CHECKSTYLE_BUNDLE, DefaultLogger.ADD_EXCEPTION_MESSAGE,
            new String[] {"myfile"}, null,
            getClass(), null);
    final LocalizedMessage startMessage = new LocalizedMessage(0,
            Definitions.CHECKSTYLE_BUNDLE, DefaultLogger.AUDIT_STARTED_MESSAGE,
            CommonUtils.EMPTY_STRING_ARRAY, null,
            getClass(), null);
    final LocalizedMessage finishMessage = new LocalizedMessage(0,
            Definitions.CHECKSTYLE_BUNDLE, DefaultLogger.AUDIT_FINISHED_MESSAGE,
            CommonUtils.EMPTY_STRING_ARRAY, null,
            getClass(), null);

    verify(infoStream, times(1)).close();
    verify(errorStream, times(1)).close();
    final String infoOutput = infoStream.toString();
    assertTrue("Message should contain exception info, but was " + infoOutput,
            infoOutput.contains(startMessage.getMessage()));
    assertTrue("Message should contain exception info, but was " + infoOutput,
            infoOutput.contains(finishMessage.getMessage()));
    assertTrue("Message should contain exception info, but was " + output,
            output.contains(addExceptionMessage.getMessage()));
    assertTrue("Message should contain exception info, but was " + output,
            output.contains("java.lang.IllegalStateException: upsss"));
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:37,代码来源:DefaultLoggerTest.java


示例6: testNewCtorWithTwoParameters

import com.puppycrawl.tools.checkstyle.api.AutomaticBean; //导入依赖的package包/类
@Test
public void testNewCtorWithTwoParameters() {
    final OutputStream infoStream = new ByteArrayOutputStream();
    final DefaultLogger dl = new DefaultLogger(infoStream,
            AutomaticBean.OutputStreamOptions.NONE);
    dl.addException(new AuditEvent(5000, "myfile"), new IllegalStateException("upsss"));
    dl.auditFinished(new AuditEvent(6000, "myfile"));
    assertTrue("Message should contain exception info, but was " + infoStream,
            infoStream.toString().contains("java.lang.IllegalStateException: upsss"));
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:11,代码来源:DefaultLoggerTest.java


示例7: testFinishLocalSetup

import com.puppycrawl.tools.checkstyle.api.AutomaticBean; //导入依赖的package包/类
@Test
public void testFinishLocalSetup() throws CheckstyleException {
    final OutputStream infoStream = new ByteArrayOutputStream();
    final DefaultLogger dl = new DefaultLogger(infoStream,
            AutomaticBean.OutputStreamOptions.CLOSE);
    dl.finishLocalSetup();
    dl.auditStarted(null);
    dl.auditFinished(null);
    assertNotNull("instance should not be null", dl);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:11,代码来源:DefaultLoggerTest.java


示例8: createListener

import com.puppycrawl.tools.checkstyle.api.AutomaticBean; //导入依赖的package包/类
/**
 * Creates the audit listener.
 *
 * @param format format of the audit listener
 * @param outputLocation the location of output
 * @return a fresh new {@code AuditListener}
 * @exception FileNotFoundException when provided output location is not found
 * @noinspection IOResourceOpenedButNotSafelyClosed
 */
private static AuditListener createListener(String format,
                                            String outputLocation)
        throws FileNotFoundException {
    // setup the output stream
    final OutputStream out;
    final AutomaticBean.OutputStreamOptions closeOutputStream;
    if (outputLocation == null) {
        out = System.out;
        closeOutputStream = AutomaticBean.OutputStreamOptions.NONE;
    }
    else {
        out = new FileOutputStream(outputLocation);
        closeOutputStream = AutomaticBean.OutputStreamOptions.CLOSE;
    }

    // setup a listener
    final AuditListener listener;
    if (XML_FORMAT_NAME.equals(format)) {
        listener = new XMLLogger(out, closeOutputStream);
    }
    else if (PLAIN_FORMAT_NAME.equals(format)) {
        listener = new DefaultLogger(out, closeOutputStream, out,
                AutomaticBean.OutputStreamOptions.NONE);
    }
    else {
        if (closeOutputStream == AutomaticBean.OutputStreamOptions.CLOSE) {
            CommonUtils.close(out);
        }
        final LocalizedMessage outputFormatExceptionMessage = new LocalizedMessage(0,
                Definitions.CHECKSTYLE_BUNDLE, CREATE_LISTENER_EXCEPTION,
                new String[] {format, PLAIN_FORMAT_NAME, XML_FORMAT_NAME}, null,
                Main.class, null);
        throw new IllegalStateException(outputFormatExceptionMessage.getMessage());
    }

    return listener;
}
 
开发者ID:checkstyle,项目名称:checkstyle,代码行数:47,代码来源:Main.java


示例9: createListener

import com.puppycrawl.tools.checkstyle.api.AutomaticBean; //导入依赖的package包/类
/**
 * Creates the audit listener.
 *
 * @param format format of the audit listener
 * @param outputLocation the location of output
 * @return a fresh new {@code AuditListener}
 * @exception FileNotFoundException when provided output location is not found
 * @noinspection IOResourceOpenedButNotSafelyClosed
 */
private static AuditListener createListener(String format,
                                            String outputLocation)
        throws FileNotFoundException {

    // setup the output stream
    final OutputStream out;
    final AutomaticBean.OutputStreamOptions closeOutputStream;
    if (outputLocation == null) {
        out = System.out;
        closeOutputStream = AutomaticBean.OutputStreamOptions.NONE;
    }
    else {
        out = new FileOutputStream(outputLocation);
        closeOutputStream = AutomaticBean.OutputStreamOptions.CLOSE;
    }

    // setup a listener
    final AuditListener listener;
    if (XML_FORMAT_NAME.equals(format)) {
        listener = new XMLLogger(out, closeOutputStream);

    }
    else if (PLAIN_FORMAT_NAME.equals(format)) {
        listener = new DefaultLogger(out, closeOutputStream, out,
                AutomaticBean.OutputStreamOptions.NONE);

    }
    else {
        if (closeOutputStream == AutomaticBean.OutputStreamOptions.CLOSE) {
            CommonUtils.close(out);
        }
        final LocalizedMessage outputFormatExceptionMessage = new LocalizedMessage(0,
                Definitions.CHECKSTYLE_BUNDLE, CREATE_LISTENER_EXCEPTION,
                new String[] {format, PLAIN_FORMAT_NAME, XML_FORMAT_NAME}, null,
                Main.class, null);
        throw new IllegalStateException(outputFormatExceptionMessage.getMessage());
    }

    return listener;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:50,代码来源:Main.java


示例10: testLogOutput

import com.puppycrawl.tools.checkstyle.api.AutomaticBean; //导入依赖的package包/类
@Test
public void testLogOutput() throws Exception {
    final DefaultConfiguration checkConfig = createModuleConfig(TranslationCheck.class);
    checkConfig.addAttribute("requiredTranslations", "ja,de");
    checkConfig.addAttribute("baseName", "^InputTranslation.*$");
    final Checker checker = createChecker(checkConfig);
    checker.setBasedir(getPath(""));
    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    final XMLLogger logger = new XMLLogger(out, AutomaticBean.OutputStreamOptions.NONE);
    checker.addListener(logger);

    final String defaultProps = getPath("InputTranslationCheckFireErrors.properties");
    final String translationProps = getPath("InputTranslationCheckFireErrors_de.properties");

    final File[] propertyFiles = {
        new File(defaultProps),
        new File(translationProps),
    };

    final String line = "0: ";
    final String firstErrorMessage = getCheckMessage(MSG_KEY_MISSING_TRANSLATION_FILE,
            "InputTranslationCheckFireErrors_ja.properties");
    final String secondErrorMessage = getCheckMessage(MSG_KEY, "anotherKey");

    verify(checker, propertyFiles, ImmutableMap.of(
        ":0", Collections.singletonList(" " + firstErrorMessage),
        "InputTranslationCheckFireErrors_de.properties",
            Collections.singletonList(line + secondErrorMessage)));

    verifyXml(getPath("ExpectedTranslationLog.xml"), out,
        new BiPredicate<Node, Node>() {
            @Override
            public boolean test(Node expected, Node actual) {
                // order is not always maintained here for an unknown reason.
                // File names can appear in different orders depending on the OS and VM.
                // This ensures we pick up the correct file based on its name and the
                // number of children it has.
                return !"file".equals(expected.getNodeName())
                        || expected.getAttributes().getNamedItem("name").getNodeValue()
                                .equals(actual.getAttributes().getNamedItem("name").getNodeValue())
                        && XmlUtil.getChildrenElements(expected).size() == XmlUtil
                                .getChildrenElements(actual).size();
            }
        }, firstErrorMessage, secondErrorMessage);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:46,代码来源:TranslationCheckTest.java


示例11: testLogOutput

import com.puppycrawl.tools.checkstyle.api.AutomaticBean; //导入依赖的package包/类
@Test
public void testLogOutput() throws Exception {
    final DefaultConfiguration checkConfig = createModuleConfig(TranslationCheck.class);
    checkConfig.addAttribute("requiredTranslations", "ja,de");
    checkConfig.addAttribute("baseName", "^InputTranslation.*$");
    final Checker checker = createChecker(checkConfig);
    checker.setBasedir(getPath(""));
    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    final XMLLogger logger = new XMLLogger(out, AutomaticBean.OutputStreamOptions.NONE);
    checker.addListener(logger);

    final String defaultProps = getPath("InputTranslationCheckFireErrors.properties");
    final String translationProps = getPath("InputTranslationCheckFireErrors_de.properties");

    final File[] propertyFiles = {
        new File(defaultProps),
        new File(translationProps),
    };

    final String line = "0: ";
    final String firstErrorMessage = getCheckMessage(MSG_KEY_MISSING_TRANSLATION_FILE,
            "InputTranslationCheckFireErrors_ja.properties");
    final String secondErrorMessage = getCheckMessage(MSG_KEY, "anotherKey");

    verify(checker, propertyFiles, ImmutableMap.of(
        ":0", Collections.singletonList(" " + firstErrorMessage),
        "InputTranslationCheckFireErrors_de.properties",
            Collections.singletonList(line + secondErrorMessage)));

    verifyXml(getPath("ExpectedTranslationLog.xml"), out, (expected, actual) -> {
        // order is not always maintained here for an unknown reason.
        // File names can appear in different orders depending on the OS and VM.
        // This ensures we pick up the correct file based on its name and the
        // number of children it has.
        return !"file".equals(expected.getNodeName())
                || expected.getAttributes().getNamedItem("name").getNodeValue()
                        .equals(actual.getAttributes().getNamedItem("name").getNodeValue())
                && XmlUtil.getChildrenElements(expected).size() == XmlUtil
                        .getChildrenElements(actual).size();
    }, firstErrorMessage, secondErrorMessage);
}
 
开发者ID:checkstyle,项目名称:checkstyle,代码行数:42,代码来源:TranslationCheckTest.java


示例12: isValidCheckstyleClass

import com.puppycrawl.tools.checkstyle.api.AutomaticBean; //导入依赖的package包/类
/**
 * Checks whether a class extends 'AutomaticBean', is non-abstract, and doesn't start with the
 * word 'Input' (are not input files for UTs).
 * @param loadedClass class to check.
 * @param className class name to check.
 * @return true if a class may be considered a valid production class.
 */
public static boolean isValidCheckstyleClass(Class<?> loadedClass, String className) {
    return AutomaticBean.class.isAssignableFrom(loadedClass)
            && !Modifier.isAbstract(loadedClass.getModifiers())
            && !className.contains("Input");
}
 
开发者ID:checkstyle,项目名称:sonar-checkstyle,代码行数:13,代码来源:CheckUtil.java


示例13: isValidCheckstyleClass

import com.puppycrawl.tools.checkstyle.api.AutomaticBean; //导入依赖的package包/类
/**
 * Checks whether a class extends 'AutomaticBean', is non-abstract, and has a default
 * constructor.
 * @param clazz class to check.
 * @return true if a class may be considered a valid production class.
 */
public static boolean isValidCheckstyleClass(Class<?> clazz) {
    return AutomaticBean.class.isAssignableFrom(clazz)
            && !Modifier.isAbstract(clazz.getModifiers())
            && hasDefaultConstructor(clazz);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:12,代码来源:ModuleReflectionUtils.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Column类代码示例发布时间:2022-05-23
下一篇:
Java SmartWatchConst类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap