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


Java CommonUtils.endsWithChar方法代码示例

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


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

示例1: visitToken

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
@Override
public void visitToken(DetailAST ast) {
    if (CommonUtils.endsWithChar(ast.getText(), 'l')) {
        log(ast.getLineNo(),
            ast.getColumnNo() + ast.getText().length() - 1,
            MSG_KEY);
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:9,代码来源:UpperEllCheck.java

示例2: setGroups

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Sets the list of package groups and the order they should occur in the
 * file.
 *
 * @param packageGroups a comma-separated list of package names/prefixes.
 */
public void setGroups(String... packageGroups) {
    groups = new Pattern[packageGroups.length];

    for (int i = 0; i < packageGroups.length; i++) {
        String pkg = packageGroups[i];
        final Pattern grp;

        // if the pkg name is the wildcard, make it match zero chars
        // from any name, so it will always be used as last resort.
        if (WILDCARD_GROUP_NAME.equals(pkg)) {
            // matches any package
            grp = Pattern.compile("");
        }
        else if (CommonUtils.startsWithChar(pkg, '/')) {
            if (!CommonUtils.endsWithChar(pkg, '/')) {
                throw new IllegalArgumentException("Invalid group");
            }
            pkg = pkg.substring(1, pkg.length() - 1);
            grp = Pattern.compile(pkg);
        }
        else {
            final StringBuilder pkgBuilder = new StringBuilder(pkg);
            if (!CommonUtils.endsWithChar(pkg, '.')) {
                pkgBuilder.append('.');
            }
            grp = Pattern.compile("^" + Pattern.quote(pkgBuilder.toString()));
        }

        groups[i] = grp;
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:38,代码来源:ImportOrderCheck.java

示例3: getPackageName

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Creates a full package name from the package names on the stack.
 * @return the full name of the current package.
 */
private String getPackageName() {
    final StringBuilder buf = new StringBuilder(256);
    final Iterator<String> iterator = packageStack.descendingIterator();
    while (iterator.hasNext()) {
        final String subPackage = iterator.next();
        buf.append(subPackage);
        if (!CommonUtils.endsWithChar(subPackage, '.') && iterator.hasNext()) {
            buf.append('.');
        }
    }
    return buf.toString();
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:17,代码来源:PackageNamesLoader.java

示例4: isReference

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Finds whether the given argument is character or entity reference.
 * @param ent the possible entity to look for.
 * @return whether the given argument a character or entity reference
 */
public static boolean isReference(String ent) {
    boolean reference = false;

    if (ent.charAt(0) != '&' || !CommonUtils.endsWithChar(ent, ';')) {
        reference = false;
    }
    else if (ent.charAt(1) == '#') {
        // prefix is "&#"
        int prefixLength = 2;

        int radix = BASE_10;
        if (ent.charAt(2) == 'x') {
            prefixLength++;
            radix = BASE_16;
        }
        try {
            Integer.parseInt(
                ent.substring(prefixLength, ent.length() - 1), radix);
            reference = true;
        }
        catch (final NumberFormatException ignored) {
            reference = false;
        }
    }
    else {
        final String name = ent.substring(1, ent.length() - 1);
        for (String element : ENTITIES) {
            if (name.equals(element)) {
                reference = true;
                break;
            }
        }
    }
    return reference;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:41,代码来源:XMLLogger.java

示例5: checkParamTags

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Checks a set of tags for matching parameters.
 *
 * @param tags the tags to check
 * @param parent the node which takes the parameters
 * @param reportExpectedTags whether we should report if do not find
 *            expected tag
 */
private void checkParamTags(final List<JavadocTag> tags,
        final DetailAST parent, boolean reportExpectedTags) {
    final List<DetailAST> params = getParameters(parent);
    final List<DetailAST> typeParams = CheckUtils
            .getTypeParameters(parent);

    // Loop over the tags, checking to see they exist in the params.
    final ListIterator<JavadocTag> tagIt = tags.listIterator();
    while (tagIt.hasNext()) {
        final JavadocTag tag = tagIt.next();

        if (!tag.isParamTag()) {
            continue;
        }

        tagIt.remove();

        final String arg1 = tag.getFirstArg();
        boolean found = removeMatchingParam(params, arg1);

        if (CommonUtils.startsWithChar(arg1, '<') && CommonUtils.endsWithChar(arg1, '>')) {
            found = searchMatchingTypeParameter(typeParams,
                    arg1.substring(1, arg1.length() - 1));

        }

        // Handle extra JavadocTag
        if (!found) {
            log(tag.getLineNo(), tag.getColumnNo(), MSG_UNUSED_TAG,
                    "@param", arg1);
        }
    }

    // Now dump out all type parameters/parameters without tags :- unless
    // the user has chosen to suppress these problems
    if (!allowMissingParamTags && reportExpectedTags) {
        for (DetailAST param : params) {
            log(param, MSG_EXPECTED_TAG,
                JavadocTagInfo.PARAM.getText(), param.getText());
        }

        for (DetailAST typeParam : typeParams) {
            log(typeParam, MSG_EXPECTED_TAG,
                JavadocTagInfo.PARAM.getText(),
                "<" + typeParam.findFirstToken(TokenTypes.IDENT).getText()
                + ">");
        }
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:58,代码来源:JavadocMethodCheck.java


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