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


Java CommonUtils.isBlank方法代码示例

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


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

示例1: convert

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public Object convert(Class type, Object value) {
    final String url = value.toString();
    URI result = null;

    if (!CommonUtils.isBlank(url)) {
        try {
            result = CommonUtils.getUriByFilename(url);
        }
        catch (CheckstyleException ex) {
            throw new IllegalArgumentException(ex);
        }
    }

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

示例2: visitToken

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
@Override
public void visitToken(DetailAST ast) {
    final DetailAST parent = ast.getParent();
    //we do not want to check colon for cases and defaults
    if (ast.getType() != TokenTypes.COLON
            || parent.getType() != TokenTypes.LITERAL_DEFAULT
                && parent.getType() != TokenTypes.LITERAL_CASE) {
        final String text = ast.getText();
        final int colNo = ast.getColumnNo();
        final int lineNo = ast.getLineNo();
        final String currentLine = getLine(lineNo - 1);

        // Check if rest of line is whitespace, and not just the operator
        // by itself. This last bit is to handle the operator on a line by
        // itself.
        if (option == WrapOption.NL
                && !text.equals(currentLine.trim())
                && CommonUtils.isBlank(currentLine.substring(colNo + text.length()))) {
            log(lineNo, colNo, MSG_LINE_NEW, text);
        }
        else if (option == WrapOption.EOL
                && CommonUtils.hasWhitespaceBefore(colNo - 1, currentLine)) {
            log(lineNo, colNo, MSG_LINE_PREVIOUS, text);
        }
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:27,代码来源:OperatorWrapCheck.java

示例3: startsWithInheritDoc

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Checks if the node starts with an {@inheritDoc}.
 * @param root The root node to examine.
 * @return {@code true} if the javadoc starts with an {@inheritDoc}.
 */
private static boolean startsWithInheritDoc(DetailNode root) {
    boolean found = false;
    final DetailNode[] children = root.getChildren();

    for (int i = 0; !found && i < children.length - 1; i++) {
        final DetailNode child = children[i];
        if (child.getType() == JavadocTokenTypes.JAVADOC_INLINE_TAG
                && child.getChildren()[1].getType() == JavadocTokenTypes.INHERIT_DOC_LITERAL) {
            found = true;
        }
        else if (child.getType() != JavadocTokenTypes.LEADING_ASTERISK
                && !CommonUtils.isBlank(child.getText())) {
            break;
        }
    }

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

示例4: getSummarySentence

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Checks if period is at the end of sentence.
 * @param ast Javadoc root node.
 * @return error string
 */
private static String getSummarySentence(DetailNode ast) {
    boolean flag = true;
    final StringBuilder result = new StringBuilder(256);
    for (DetailNode child : ast.getChildren()) {
        if (ALLOWED_TYPES.contains(child.getType())) {
            result.append(child.getText());
        }
        else if (child.getType() == JavadocTokenTypes.HTML_ELEMENT
                && CommonUtils.isBlank(result.toString().trim())) {
            result.append(getStringInsideTag(result.toString(),
                    child.getChildren()[0].getChildren()[0]));
        }
        else if (child.getType() == JavadocTokenTypes.JAVADOC_TAG) {
            flag = false;
        }
        if (!flag) {
            break;
        }
    }
    return result.toString().trim();
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:27,代码来源:SummaryJavadocCheck.java

示例5: isFirstParagraph

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Determines whether or not the line with paragraph tag is first line in javadoc.
 * @param paragraphTag paragraph tag.
 * @return true, if line with paragraph tag is first line in javadoc.
 */
private static boolean isFirstParagraph(DetailNode paragraphTag) {
    boolean result = true;
    DetailNode previousNode = JavadocUtils.getPreviousSibling(paragraphTag);
    while (previousNode != null) {
        if (previousNode.getType() == JavadocTokenTypes.TEXT
                && !CommonUtils.isBlank(previousNode.getText())
            || previousNode.getType() != JavadocTokenTypes.LEADING_ASTERISK
                && previousNode.getType() != JavadocTokenTypes.NEWLINE
                && previousNode.getType() != JavadocTokenTypes.TEXT) {
            result = false;
            break;
        }
        previousNode = JavadocUtils.getPreviousSibling(previousNode);
    }
    return result;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:22,代码来源:JavadocParagraphCheck.java

示例6: visitJavadocToken

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
@Override
public void visitJavadocToken(DetailNode ast) {
    if (!isInlineDescription(ast)) {
        final List<DetailNode> textNodes = getAllNewlineNodes(ast);
        for (DetailNode newlineNode : textNodes) {
            final DetailNode textNode = JavadocUtils.getNextSibling(JavadocUtils
                    .getNextSibling(newlineNode));
            if (textNode != null && textNode.getType() == JavadocTokenTypes.TEXT) {
                final String text = textNode.getText();
                if (!CommonUtils.isBlank(text.trim())
                        && (text.length() <= offset
                                || !text.substring(1, offset + 1).trim().isEmpty())) {
                    log(textNode.getLineNumber(), MSG_KEY, offset);
                }
            }
        }
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:19,代码来源:JavadocTagContinuationIndentationCheck.java

示例7: setHeader

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Set the header to check against. Individual lines in the header
 * must be separated by '\n' characters.
 * @param header header content to check against.
 * @throws IllegalArgumentException if the header cannot be interpreted
 */
public void setHeader(String header) {
    if (!CommonUtils.isBlank(header)) {
        checkHeaderNotInitialized();

        final String headerExpandedNewLines = ESCAPED_LINE_FEED_PATTERN
                .matcher(header).replaceAll("\n");

        final Reader headerReader = new StringReader(headerExpandedNewLines);
        try {
            loadHeader(headerReader);
        }
        catch (final IOException ex) {
            throw new IllegalArgumentException("unable to load header", ex);
        }
        finally {
            Closeables.closeQuietly(headerReader);
        }
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:26,代码来源:AbstractHeaderCheck.java

示例8: hasText

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Checks if SLIST token contains any text.
 * @param slistAST a {@code DetailAST} value
 * @return whether the SLIST token contains any text.
 */
private boolean hasText(final DetailAST slistAST) {
    final DetailAST rightCurly = slistAST.findFirstToken(TokenTypes.RCURLY);
    final DetailAST rcurlyAST;

    if (rightCurly == null) {
        rcurlyAST = slistAST.getParent().findFirstToken(TokenTypes.RCURLY);
    }
    else {
        rcurlyAST = rightCurly;
    }
    final int slistLineNo = slistAST.getLineNo();
    final int slistColNo = slistAST.getColumnNo();
    final int rcurlyLineNo = rcurlyAST.getLineNo();
    final int rcurlyColNo = rcurlyAST.getColumnNo();
    final String[] lines = getLines();
    boolean returnValue = false;
    if (slistLineNo == rcurlyLineNo) {
        // Handle braces on the same line
        final String txt = lines[slistLineNo - 1]
                .substring(slistColNo + 1, rcurlyColNo);
        if (!CommonUtils.isBlank(txt)) {
            returnValue = true;
        }
    }
    else {
        final String firstLine = lines[slistLineNo - 1].substring(slistColNo + 1);
        final String lastLine = lines[rcurlyLineNo - 1].substring(0, rcurlyColNo);
        // check if all lines are also only whitespace
        returnValue = !(CommonUtils.isBlank(firstLine) && CommonUtils.isBlank(lastLine))
                || !checkIsAllLinesAreWhitespace(lines, slistLineNo, rcurlyLineNo);
    }
    return returnValue;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:39,代码来源:EmptyBlockCheck.java

示例9: isPrePreviousLineEmpty

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Checks if a token has empty pre-previous line.
 * @param token DetailAST token.
 * @return true, if token has empty lines before.
 */
private boolean isPrePreviousLineEmpty(DetailAST token) {
    boolean result = false;
    final int lineNo = token.getLineNo();
    // 3 is the number of the pre-previous line because the numbering starts from zero.
    final int number = 3;
    if (lineNo >= number) {
        final String prePreviousLine = getLines()[lineNo - number];
        result = CommonUtils.isBlank(prePreviousLine);
    }
    return result;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:17,代码来源:EmptyLineSeparatorCheck.java

示例10: beginTree

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
@Override
public void beginTree(DetailAST rootAST) {
    final Map<Integer, TextBlock> cppComments = getFileContents()
            .getSingleLineComments();
    final Map<Integer, List<TextBlock>> cComments = getFileContents()
            .getBlockComments();
    final Set<Integer> lines = new HashSet<Integer>();
    lines.addAll(cppComments.keySet());
    lines.addAll(cComments.keySet());

    for (Integer lineNo : lines) {
        final String line = getLines()[lineNo - 1];
        final String lineBefore;
        final TextBlock comment;
        if (cppComments.containsKey(lineNo)) {
            comment = cppComments.get(lineNo);
            lineBefore = line.substring(0, comment.getStartColNo());
        }
        else {
            final List<TextBlock> commentList = cComments.get(lineNo);
            comment = commentList.get(commentList.size() - 1);
            lineBefore = line.substring(0, comment.getStartColNo());

            // do not check comment which doesn't end line
            if (comment.getText().length == 1
                    && !CommonUtils.isBlank(line
                        .substring(comment.getEndColNo() + 1))) {
                continue;
            }
        }
        if (!format.matcher(lineBefore).find()
            && !isLegalComment(comment)) {
            log(lineNo, MSG_KEY);
        }
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:37,代码来源:TrailingCommentCheck.java

示例11: checkEmptyLine

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Determines whether or not the next line after empty line has paragraph tag in the beginning.
 * @param newline NEWLINE node.
 */
private void checkEmptyLine(DetailNode newline) {
    final DetailNode nearestToken = getNearestNode(newline);
    if (!isLastEmptyLine(newline) && nearestToken.getType() == JavadocTokenTypes.TEXT
            && !CommonUtils.isBlank(nearestToken.getText())) {
        log(newline.getLineNumber(), MSG_TAG_AFTER);
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:12,代码来源:JavadocParagraphCheck.java

示例12: isEmptyLine

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Determines whether or not the line is empty line.
 * @param newLine NEWLINE node.
 * @return true, if line is empty line.
 */
private static boolean isEmptyLine(DetailNode newLine) {
    boolean result = false;
    DetailNode previousSibling = JavadocUtils.getPreviousSibling(newLine);
    if (previousSibling != null
            && previousSibling.getParent().getType() == JavadocTokenTypes.JAVADOC) {
        if (previousSibling.getType() == JavadocTokenTypes.TEXT
                && CommonUtils.isBlank(previousSibling.getText())) {
            previousSibling = JavadocUtils.getPreviousSibling(previousSibling);
        }
        result = previousSibling != null
                && previousSibling.getType() == JavadocTokenTypes.LEADING_ASTERISK;
    }
    return result;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:20,代码来源:JavadocParagraphCheck.java

示例13: isLastEmptyLine

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Tests if NEWLINE node is a last node in javadoc.
 * @param newLine NEWLINE node.
 * @return true, if NEWLINE node is a last node in javadoc.
 */
private static boolean isLastEmptyLine(DetailNode newLine) {
    boolean result = true;
    DetailNode nextNode = JavadocUtils.getNextSibling(newLine);
    while (nextNode != null && nextNode.getType() != JavadocTokenTypes.JAVADOC_TAG) {
        if (nextNode.getType() == JavadocTokenTypes.TEXT
                && !CommonUtils.isBlank(nextNode.getText())
                || nextNode.getType() == JavadocTokenTypes.HTML_ELEMENT) {
            result = false;
            break;
        }
        nextNode = JavadocUtils.getNextSibling(nextNode);
    }
    return result;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:20,代码来源:JavadocParagraphCheck.java

示例14: setHeader

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Validates the {@code header} by compiling it with
 * {@link Pattern#compile(String) } and throws
 * {@link IllegalArgumentException} if {@code header} isn't a valid pattern.
 * @param header the header value to validate and set (in that order)
 */
@Override
public void setHeader(String header) {
    if (!CommonUtils.isBlank(header)) {
        if (!CommonUtils.isPatternValid(header)) {
            throw new IllegalArgumentException("Unable to parse format: " + header);
        }
        super.setHeader(header);
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:16,代码来源:RegexpHeaderCheck.java

示例15: getCountOfEmptyLinesBefore

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Counts empty lines before given.
 * @param lineNo
 *        Line number of current import.
 * @return count of empty lines before given.
 */
private int getCountOfEmptyLinesBefore(int lineNo) {
    int result = 0;
    final String[] lines = getLines();
    //  [lineNo - 2] is the number of the previous line
    //  because the numbering starts from zero.
    int lineBeforeIndex = lineNo - 2;
    while (lineBeforeIndex >= 0
            && CommonUtils.isBlank(lines[lineBeforeIndex])) {
        lineBeforeIndex--;
        result++;
    }
    return result;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:20,代码来源:CustomImportOrderCheck.java


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