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


Java Configuration.getAttribute方法代码示例

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


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

示例1: testClassDefault

import com.puppycrawl.tools.checkstyle.api.Configuration; //导入方法依赖的package包/类
@Test
public void testClassDefault() throws Exception {
    final Configuration configuration = getModuleConfig("ClassTypeParameterName");
    final String format = configuration.getAttribute("format");

    final String[] expected = {
        "5:31: " + getCheckMessage(configuration.getMessages(), MSG_KEY, "t", format),
        "13:14: " + getCheckMessage(configuration.getMessages(), MSG_KEY, "foo", format),
        "27:24: " + getCheckMessage(configuration.getMessages(), MSG_KEY, "$foo", format),
    };

    final String filePath = getPath("InputClassTypeParameterName.java");

    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(configuration, filePath, expected, warnList);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:17,代码来源:ClassTypeParameterNameTest.java

示例2: testInterfaceDefault

import com.puppycrawl.tools.checkstyle.api.Configuration; //导入方法依赖的package包/类
@Test
public void testInterfaceDefault() throws Exception {
    final Configuration configuration = getModuleConfig("InterfaceTypeParameterName");
    final String format = configuration.getAttribute("format");

    final String[] expected = {
        "48:15: " + getCheckMessage(configuration.getMessages(), MSG_KEY, "Input", format),
        "76:25: " + getCheckMessage(configuration.getMessages(), MSG_KEY, "Request", format),
        "80:25: " + getCheckMessage(configuration.getMessages(), MSG_KEY, "TRequest", format),
    };

    final String filePath = getPath("InputInterfaceTypeParameterName.java");

    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(configuration, filePath, expected, warnList);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:17,代码来源:InterfaceTypeParameterNameTest.java

示例3: testBadPackageName

import com.puppycrawl.tools.checkstyle.api.Configuration; //导入方法依赖的package包/类
@Test
public void testBadPackageName() throws Exception {

    final String packagePath =
            "com.google.checkstyle.test.chapter5naming.rule521packageNamesCamelCase";
    final Configuration checkConfig = getModuleConfig("PackageName");
    final String format = checkConfig.getAttribute("format");
    final String msg = getCheckMessage(checkConfig.getMessages(), MSG_KEY, packagePath, format);

    final String[] expected = {
        "1:9: " + msg,
    };

    final String filePath = getPath("packageNamesCamelCase", "InputPackageNameBad.java");

    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:19,代码来源:PackageNameTest.java

示例4: testBadPackageName2

import com.puppycrawl.tools.checkstyle.api.Configuration; //导入方法依赖的package包/类
@Test
public void testBadPackageName2() throws Exception {

    final String packagePath = "com.google.checkstyle.test.chapter5naming.rule521_packagenames";
    final Configuration checkConfig = getModuleConfig("PackageName");
    final String format = checkConfig.getAttribute("format");
    final String msg = getCheckMessage(checkConfig.getMessages(), MSG_KEY, packagePath, format);

    final String[] expected = {
        "1:9: " + msg,
    };

    final String filePath = getPath("_packagenames", "InputBadPackageName2.java");

    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:18,代码来源:PackageNameTest.java

示例5: testBadPackageName3

import com.puppycrawl.tools.checkstyle.api.Configuration; //导入方法依赖的package包/类
@Test
public void testBadPackageName3() throws Exception {

    final String packagePath = "com.google.checkstyle.test.chapter5naming.rule521$packagenames";
    final Configuration checkConfig = getModuleConfig("PackageName");
    final String format = checkConfig.getAttribute("format");
    final String msg = getCheckMessage(checkConfig.getMessages(), MSG_KEY, packagePath, format);

    final String[] expected = {
        "1:9: " + msg,
    };

    final String filePath = getPath("$packagenames", "InputPackageBadName3.java");

    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:18,代码来源:PackageNameTest.java

示例6: testLocalVariableName

import com.puppycrawl.tools.checkstyle.api.Configuration; //导入方法依赖的package包/类
@Test
public void testLocalVariableName() throws Exception {

    final Configuration checkConfig = getModuleConfig("LocalVariableName");
    final String format = checkConfig.getAttribute("format");
    final String[] expected = {
        "27:13: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "aA", format),
        "28:13: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "a1_a", format),
        "29:13: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "A_A", format),
        "30:13: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "aa2_a", format),
        "31:13: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "_a", format),
        "32:13: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "_aa", format),
        "33:13: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "aa_", format),
        "34:13: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "aaa$aaa", format),
        "35:13: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "$aaaaaa", format),
        "36:13: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "aaaaaa$", format),
    };

    final String filePath = getPath("InputLocalVariableNameSimple.java");

    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:24,代码来源:LocalVariableNameTest.java

示例7: testOneChar

import com.puppycrawl.tools.checkstyle.api.Configuration; //导入方法依赖的package包/类
@Test
public void testOneChar() throws Exception {

    final Configuration checkConfig = getModuleConfig("LocalVariableName");
    final String format = checkConfig.getAttribute("format");
    final String[] expected = {
        "21:17: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "I_ndex", format),
        "45:17: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "i_ndex", format),
        "49:17: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "ii_i1", format),
        "53:17: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "$index", format),
        "57:17: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "in$dex", format),
        "61:17: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "index$", format),
    };

    final String filePath = getPath("InputLocalVariableNameOneCharVarName.java");

    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:20,代码来源:LocalVariableNameTest.java

示例8: testCatchParameterName

import com.puppycrawl.tools.checkstyle.api.Configuration; //导入方法依赖的package包/类
@Test
public void testCatchParameterName() throws Exception {
    final String msgKey = "name.invalidPattern";
    final Configuration checkConfig = getModuleConfig("CatchParameterName");
    final String format = checkConfig.getAttribute("format");

    final String[] expected = {
        "47:28: " + getCheckMessage(checkConfig.getMessages(), msgKey, "iException", format),
        "50:28: " + getCheckMessage(checkConfig.getMessages(), msgKey, "ex_1", format),
        "53:28: " + getCheckMessage(checkConfig.getMessages(), msgKey, "eX", format),
        "56:28: " + getCheckMessage(checkConfig.getMessages(), msgKey, "eXX", format),
        "59:28: " + getCheckMessage(checkConfig.getMessages(), msgKey, "x_y_z", format),
        "62:28: " + getCheckMessage(checkConfig.getMessages(), msgKey, "Ex", format),
    };

    final String filePath = getPath("InputCatchParameterName.java");

    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:21,代码来源:CatchParameterNameTest.java

示例9: testMemberName

import com.puppycrawl.tools.checkstyle.api.Configuration; //导入方法依赖的package包/类
@Test
public void testMemberName() throws Exception {

    final Configuration checkConfig = getModuleConfig("MemberName");
    final String format = checkConfig.getAttribute("format");
    final String[] expected = {
        "5:16: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "mPublic", format),
        "6:19: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "mProtected", format),
        "7:9: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "mPackage", format),
        "8:17: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "mPrivate", format),
        "10:16: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "_public", format),
        "11:19: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "prot_ected", format),
        "12:9: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "package_", format),
        "13:17: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "priva$te", format),
        "20:9: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "ABC", format),
        "21:15: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "C_D_E", format),
        "23:16: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "$mPublic", format),
        "24:19: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "mPro$tected", format),
        "25:9: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "mPackage$", format),
    };

    final String filePath = getPath("InputMemberNameBasic.java");

    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:27,代码来源:MemberNameTest.java

示例10: testGeneralParameterName

import com.puppycrawl.tools.checkstyle.api.Configuration; //导入方法依赖的package包/类
@Test
public void testGeneralParameterName() throws Exception {

    final Configuration config = getModuleConfig("ParameterName");
    final String format = config.getAttribute("format");
    final String[] expected = {
        "10:21: " + getCheckMessage(config.getMessages(), MSG_KEY, "bB", format),
        "33:22: " + getCheckMessage(config.getMessages(), MSG_KEY, "llll_llll", format),
        "34:21: " + getCheckMessage(config.getMessages(), MSG_KEY, "bB", format),
        "64:13: " + getCheckMessage(config.getMessages(), MSG_KEY, "$arg1", format),
        "65:13: " + getCheckMessage(config.getMessages(), MSG_KEY, "ar$g2", format),
        "66:13: " + getCheckMessage(config.getMessages(), MSG_KEY, "arg3$", format),
        "67:13: " + getCheckMessage(config.getMessages(), MSG_KEY, "a_rg4", format),
        "68:13: " + getCheckMessage(config.getMessages(), MSG_KEY, "_arg5", format),
        "69:13: " + getCheckMessage(config.getMessages(), MSG_KEY, "arg6_", format),
        "70:13: " + getCheckMessage(config.getMessages(), MSG_KEY, "aArg7", format),
        "71:13: " + getCheckMessage(config.getMessages(), MSG_KEY, "aArg8", format),
        "72:13: " + getCheckMessage(config.getMessages(), MSG_KEY, "aar_g", format),
    };

    final String filePath = getPath("InputParameterName.java");

    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(config, filePath, expected, warnList);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:26,代码来源:ParameterNameTest.java

示例11: endElement

import com.puppycrawl.tools.checkstyle.api.Configuration; //导入方法依赖的package包/类
@Override
public void endElement(String uri,
                       String localName,
                       String qName) throws SAXException {
    if (qName.equals(MODULE)) {

        final Configuration recentModule =
            configStack.pop();

        // get severity attribute if it exists
        SeverityLevel level = null;
        if (containsAttribute(recentModule, SEVERITY)) {
            try {
                final String severity = recentModule.getAttribute(SEVERITY);
                level = SeverityLevel.getInstance(severity);
            }
            catch (final CheckstyleException ex) {
                // [email protected][IllegalInstantiation] SAXException is in the overridden
                // method signature
                throw new SAXException(
                        "Problem during accessing '" + SEVERITY + "' attribute for "
                                + recentModule.getName(), ex);
            }
        }

        // omit this module if these should be omitted and the module
        // has the severity 'ignore'
        final boolean omitModule = omitIgnoredModules
            && level == SeverityLevel.IGNORE;

        if (omitModule && !configStack.isEmpty()) {
            final DefaultConfiguration parentModule =
                configStack.peek();
            parentModule.removeChild(recentModule);
        }
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:38,代码来源:ConfigurationLoader.java

示例12: testSimple

import com.puppycrawl.tools.checkstyle.api.Configuration; //导入方法依赖的package包/类
@Test
public void testSimple() throws Exception {

    final Configuration checkConfig = getModuleConfig("MemberName");
    final String format = checkConfig.getAttribute("format");
    final String[] expected = {
        "12:17: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "bad$Static", format),
        "17:17: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "bad_Member", format),
        "19:17: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "m", format),
        "21:19: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "m_M", format),
        "24:19: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "m$nts", format),
        "35:9: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "mTest1", format),
        "37:16: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "mTest2", format),
        "39:16: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "$mTest2", format),
        "41:16: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "mTes$t2", format),
        "43:16: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "mTest2$", format),
        "77:21: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "bad$Static", format),
        "79:22: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "sum_Created", format),
        "82:21: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "bad_Member", format),
        "84:21: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "m", format),
        "86:23: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "m_M", format),
        "89:23: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "m$nts", format),
        "93:13: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "mTest1", format),
        "95:20: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "mTest2", format),
        "97:20: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "$mTest2", format),
        "99:20: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "mTes$t2", format),
        "101:20: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "mTest2$", format),
        "107:25: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "bad$Static", format),
        "109:25: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "sum_Created", format),
        "112:25: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "bad_Member", format),
        "114:25: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "m", format),
        "116:25: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "m_M", format),
        "119:27: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "m$nts", format),
        "123:25: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "mTest1", format),
        "125:25: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "mTest2", format),
        "127:25: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "$mTest2", format),
        "129:25: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "mTes$t2", format),
        "131:25: " + getCheckMessage(checkConfig.getMessages(), MSG_KEY, "mTest2$", format),
    };

    final String filePath = getPath("InputMemberNameSimple.java");

    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:46,代码来源:MemberNameTest.java

示例13: configure

import com.puppycrawl.tools.checkstyle.api.Configuration; //导入方法依赖的package包/类
@Override
public void configure(Configuration configuration) throws CheckstyleException {
    config = configuration;
    property = configuration.getAttribute("property");
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:6,代码来源:TestRootModuleChecker.java


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