Class InlineTagUtil
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.checks.javadoc.utils.InlineTagUtil
-
public final class InlineTagUtil extends java.lang.Object
Tools for extracting inline tags from Javadoc comments.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringCARRIAGE_RETURNCarriage return character.private static java.util.regex.PatternINLINE_TAG_PATTERNInline tag pattern.private static java.util.regex.PatternJAVADOC_PREFIX_PATTERNPattern to recognize leading "*" characters in Javadoc.private static java.lang.StringLINE_FEEDLine feed character.private static java.util.regex.PatternNEWLINE_PATTERNPattern matching a newline.private static java.util.regex.PatternWHITESPACE_PATTERNPattern matching whitespace, used bycollapseWhitespace(String).
-
Constructor Summary
Constructors Modifier Constructor Description privateInlineTagUtil()Prevent instantiation.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.lang.StringcollapseWhitespace(java.lang.String str)Collapse whitespaces.private static java.lang.StringconvertLinesToString(java.lang.String... lines)Convert array of string to single String.static java.util.List<TagInfo>extractInlineTags(java.lang.String... lines)Extract inline Javadoc tags from the given comment.private static LineColumngetLineColumnOfIndex(java.lang.String source, int index)Get LineColumn from string till index.private static java.lang.StringremoveLeadingJavaDoc(java.lang.String source)Remove leading JavaDoc.
-
-
-
Field Detail
-
INLINE_TAG_PATTERN
private static final java.util.regex.Pattern INLINE_TAG_PATTERN
Inline tag pattern.
-
JAVADOC_PREFIX_PATTERN
private static final java.util.regex.Pattern JAVADOC_PREFIX_PATTERN
Pattern to recognize leading "*" characters in Javadoc.
-
WHITESPACE_PATTERN
private static final java.util.regex.Pattern WHITESPACE_PATTERN
Pattern matching whitespace, used bycollapseWhitespace(String).
-
NEWLINE_PATTERN
private static final java.util.regex.Pattern NEWLINE_PATTERN
Pattern matching a newline.
-
LINE_FEED
private static final java.lang.String LINE_FEED
Line feed character.- See Also:
- Constant Field Values
-
CARRIAGE_RETURN
private static final java.lang.String CARRIAGE_RETURN
Carriage return character.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
InlineTagUtil
private InlineTagUtil()
Prevent instantiation.
-
-
Method Detail
-
extractInlineTags
public static java.util.List<TagInfo> extractInlineTags(java.lang.String... lines)
Extract inline Javadoc tags from the given comment.- Parameters:
lines- The Javadoc comment (as lines).- Returns:
- The extracted inline Javadoc tags.
- Throws:
java.lang.IllegalArgumentException- when comment lines contain newlines
-
convertLinesToString
private static java.lang.String convertLinesToString(java.lang.String... lines)
Convert array of string to single String.- Parameters:
lines- A number of lines, in order.- Returns:
- The lines, joined together with newlines, as a single string.
-
getLineColumnOfIndex
private static LineColumn getLineColumnOfIndex(java.lang.String source, int index)
Get LineColumn from string till index.- Parameters:
source- Source string.index- An index into the string.- Returns:
- A position in the source representing what line and column that index appears on.
-
collapseWhitespace
private static java.lang.String collapseWhitespace(java.lang.String str)
Collapse whitespaces.- Parameters:
str- Source string.- Returns:
- The given string with all whitespace collapsed.
-
removeLeadingJavaDoc
private static java.lang.String removeLeadingJavaDoc(java.lang.String source)
Remove leading JavaDoc.- Parameters:
source- A string to remove leading Javadoc from.- Returns:
- The given string with leading Javadoc "*" characters from each line removed.
-
-