Class JavadocUtil


  • public final class JavadocUtil
    extends Object
    Contains utility methods for working with Javadoc.
    • Method Detail

      • getJavadocTags

        public static JavadocTags getJavadocTags​(TextBlock textBlock,
                                                 JavadocUtil.JavadocTagType tagType)
        Gets validTags from a given piece of Javadoc.
        Parameters:
        textBlock - the Javadoc comment to process.
        tagType - the type of validTags we're interested in
        Returns:
        all standalone validTags from the given javadoc.
      • isJavadocComment

        public static boolean isJavadocComment​(String commentContent)
        Checks that commentContent starts with '*' javadoc comment identifier.
        Parameters:
        commentContent - content of block comment
        Returns:
        true if commentContent starts with '*' javadoc comment identifier.
      • isJavadocComment

        public static boolean isJavadocComment​(DetailAST blockCommentBegin)
        Checks block comment content starts with '*' javadoc comment identifier.
        Parameters:
        blockCommentBegin - block comment AST
        Returns:
        true if block comment content starts with '*' javadoc comment identifier.
      • getJavadocCommentContent

        public static String getJavadocCommentContent​(DetailAST javadocCommentBegin)
        Get content of Javadoc comment.
        Parameters:
        javadocCommentBegin - Javadoc comment AST
        Returns:
        content of Javadoc comment.
      • findFirstToken

        public static DetailNode findFirstToken​(DetailNode detailNode,
                                                int type)
        Returns the first child token that has a specified type.
        Parameters:
        detailNode - Javadoc AST node
        type - the token type to match
        Returns:
        the matching token, or null if no match
      • getFirstChild

        public static DetailNode getFirstChild​(DetailNode node)
        Gets first child node of specified node.
        Parameters:
        node - DetailNode
        Returns:
        first child
      • containsInBranch

        public static boolean containsInBranch​(DetailNode node,
                                               int type)
        Checks whether node contains any node of specified type among children on any deep level.
        Parameters:
        node - DetailNode
        type - token type
        Returns:
        true if node contains any node of type type among children on any deep level.
      • getNextSibling

        public static DetailNode getNextSibling​(DetailNode node)
        Gets next sibling of specified node.
        Parameters:
        node - DetailNode
        Returns:
        next sibling.
      • getNextSibling

        public static DetailNode getNextSibling​(DetailNode node,
                                                int tokenType)
        Gets next sibling of specified node with the specified type.
        Parameters:
        node - DetailNode
        tokenType - javadoc token type
        Returns:
        next sibling.
      • getPreviousSibling

        public static DetailNode getPreviousSibling​(DetailNode node)
        Gets previous sibling of specified node.
        Parameters:
        node - DetailNode
        Returns:
        previous sibling
      • getTokenName

        public static String getTokenName​(int id)
        Returns the name of a token for a given ID.
        Parameters:
        id - the ID of the token name to get
        Returns:
        a token name
      • getTokenId

        public static int getTokenId​(String name)
        Returns the ID of a token for a given name.
        Parameters:
        name - the name of the token ID to get
        Returns:
        a token ID
      • getTagName

        public static String getTagName​(DetailNode javadocTagSection)
        Gets tag name from javadocTagSection.
        Parameters:
        javadocTagSection - to get tag name from.
        Returns:
        name, of the javadocTagSection's tag.
      • escapeAllControlChars

        public static String escapeAllControlChars​(String text)
        Replace all control chars with escaped symbols.
        Parameters:
        text - the String to process.
        Returns:
        the processed String with all control chars escaped.