本文整理汇总了Java中com.puppycrawl.tools.checkstyle.utils.CommonUtils.startsWithChar方法的典型用法代码示例。如果您正苦于以下问题:Java CommonUtils.startsWithChar方法的具体用法?Java CommonUtils.startsWithChar怎么用?Java CommonUtils.startsWithChar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.puppycrawl.tools.checkstyle.utils.CommonUtils
的用法示例。
在下文中一共展示了CommonUtils.startsWithChar方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setFileExtensions
import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
* Sets the file extensions that identify the files that pass the
* filter of this FileSetCheck.
* @param extensions the set of file extensions. A missing
* initial '.' character of an extension is automatically added.
* @throws IllegalArgumentException is argument is null
*/
public final void setFileExtensions(String... extensions) {
if (extensions == null) {
throw new IllegalArgumentException("Extensions array can not be null");
}
fileExtensions = new String[extensions.length];
for (int i = 0; i < extensions.length; i++) {
final String extension = extensions[i];
if (CommonUtils.startsWithChar(extension, '.')) {
fileExtensions[i] = extension;
}
else {
fileExtensions[i] = "." + extension;
}
}
}
示例2: setFileExtensions
import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
* Sets the file extensions that identify the files that pass the
* filter of this FileSetCheck.
* @param extensions the set of file extensions. A missing
* initial '.' character of an extension is automatically added.
*/
public final void setFileExtensions(String... extensions) {
if (extensions == null) {
fileExtensions = null;
}
else {
fileExtensions = new String[extensions.length];
for (int i = 0; i < extensions.length; i++) {
final String extension = extensions[i];
if (CommonUtils.startsWithChar(extension, '.')) {
fileExtensions[i] = extension;
}
else {
fileExtensions[i] = "." + extension;
}
}
}
}
示例3: isImmediatelyFollowedByText
import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
* Tests whether the paragraph tag is immediately followed by the text.
* @param tag html tag.
* @return true, if the paragraph tag is immediately followed by the text.
*/
private static boolean isImmediatelyFollowedByText(DetailNode tag) {
final DetailNode nextSibling = JavadocUtils.getNextSibling(tag);
return nextSibling.getType() == JavadocTokenTypes.NEWLINE
|| nextSibling.getType() == JavadocTokenTypes.EOF
|| CommonUtils.startsWithChar(nextSibling.getText(), ' ');
}
示例4: 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;
}
}
示例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()
+ ">");
}
}
}
示例6: Tag
import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
* Constructs a tag.
* @param text the text of the suppression.
* @param line the line number.
* @param filter the {@code SuppressWithNearbyCommentFilter} with the context
* @throws IllegalArgumentException if unable to parse expanded text.
*/
public Tag(String text, int line, SuppressWithNearbyCommentFilter filter) {
this.text = text;
//Expand regexp for check and message
//Does not intern Patterns with Utils.getPattern()
String format = "";
try {
format = CommonUtils.fillTemplateWithStringsByRegexp(
filter.checkFormat, text, filter.commentFormat);
tagCheckRegexp = Pattern.compile(format);
if (filter.messageFormat == null) {
tagMessageRegexp = null;
}
else {
format = CommonUtils.fillTemplateWithStringsByRegexp(
filter.messageFormat, text, filter.commentFormat);
tagMessageRegexp = Pattern.compile(format);
}
format = CommonUtils.fillTemplateWithStringsByRegexp(
filter.influenceFormat, text, filter.commentFormat);
if (CommonUtils.startsWithChar(format, '+')) {
format = format.substring(1);
}
final int influence = parseInfluence(format, filter.influenceFormat, text);
if (influence >= 1) {
firstLine = line;
lastLine = line + influence;
}
else {
firstLine = line + influence;
lastLine = line;
}
}
catch (final PatternSyntaxException ex) {
throw new IllegalArgumentException(
"unable to parse expanded comment " + format, ex);
}
}