Package de.gebit.integrity.utils
Class ParsedDocumentationComment
- java.lang.Object
-
- de.gebit.integrity.utils.ParsedDocumentationComment
-
public class ParsedDocumentationComment extends Object
The parsed version of a JavaDoc-style Integrity documentation comment.- Author:
- Rene Schneider - initial API and implementation
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classParsedDocumentationComment.DocCommentElementA single element of a documentation comment.static classParsedDocumentationComment.DocCommentElementTypeThe supported types of elements in documentation comments.static classParsedDocumentationComment.ParseExceptionThese exceptions are thrown by theParsedDocumentationCommentconstructors if parsing of a givenDocumentationCommentfails for whatever reason.
-
Field Summary
Fields Modifier and Type Field Description protected static StringCOMMENT_ENDA documentation comment ends with this.protected static StringCOMMENT_STARTA documentation comment starts with this.protected static PatternDOC_COMMENT_TOKENIZER_PATTERNThe pattern used to split documentation comments into elements.protected static StringDOCUMENTATION_TAG_PARAMETERThe documentation tag for parameter descriptions.protected static StringDOCUMENTATION_TAG_RESULTThe documentation tag for result descriptions.protected static StringDOCUMENTATION_TAG_RETURNThe documentation tag for result descriptions.protected static StringDOCUMENTATION_TAG_STARTThe prefix that starts a documentation tag.protected StringdocumentationTextThe core documentation text (non-parsed).protected List<ParsedDocumentationComment.DocCommentElement>documentationTextElementsThe parsed core documentation text.protected DocumentationCommentoriginThe source element that this was parsed from.protected Map<String,String>parameterDocumentationTextsDocumentation for parameters (@param).protected List<ParsedDocumentationComment.ParseException>parseExceptionsNon-critical parse exceptions that were encountered while parsing the comment.protected StringrawTextThe entire raw textual content (including @ elements, but excluding comment *s).protected Map<String,String>resultDocumentationTextsDocumentation for results (@result).protected ModelSourceInformationElementsourceInfoInformation about the source of the origin element.
-
Constructor Summary
Constructors Constructor Description ParsedDocumentationComment(DocumentationComment aComment, ModelSourceInformationElement aModelSourceInfo)Parses a givenDocumentationCommentand extracts the documentation info.ParsedDocumentationComment(DocumentationComment aComment, ModelSourceInformationElement aModelSourceInfo, boolean anAllowUnnamedResultsFlag)Parses a givenDocumentationCommentand extracts the documentation info.
-
Method Summary
-
-
-
Field Detail
-
origin
protected DocumentationComment origin
The source element that this was parsed from.
-
sourceInfo
protected ModelSourceInformationElement sourceInfo
Information about the source of the origin element.
-
parseExceptions
protected List<ParsedDocumentationComment.ParseException> parseExceptions
Non-critical parse exceptions that were encountered while parsing the comment. These exceptions did not result in an abortion of the parsing process, but point to problems nevertheless.
-
rawText
protected String rawText
The entire raw textual content (including @ elements, but excluding comment *s).
-
documentationText
protected String documentationText
The core documentation text (non-parsed).
-
documentationTextElements
protected List<ParsedDocumentationComment.DocCommentElement> documentationTextElements
The parsed core documentation text. May be empty ifdocumentationTextis empty.
-
parameterDocumentationTexts
protected Map<String,String> parameterDocumentationTexts
Documentation for parameters (@param).
-
resultDocumentationTexts
protected Map<String,String> resultDocumentationTexts
Documentation for results (@result). The one for the default result is added with key null.
-
COMMENT_START
protected static final String COMMENT_START
A documentation comment starts with this.- See Also:
- Constant Field Values
-
COMMENT_END
protected static final String COMMENT_END
A documentation comment ends with this.- See Also:
- Constant Field Values
-
DOCUMENTATION_TAG_START
protected static final String DOCUMENTATION_TAG_START
The prefix that starts a documentation tag.- See Also:
- Constant Field Values
-
DOCUMENTATION_TAG_PARAMETER
protected static final String DOCUMENTATION_TAG_PARAMETER
The documentation tag for parameter descriptions.- See Also:
- Constant Field Values
-
DOCUMENTATION_TAG_RESULT
protected static final String DOCUMENTATION_TAG_RESULT
The documentation tag for result descriptions.- See Also:
- Constant Field Values
-
DOCUMENTATION_TAG_RETURN
protected static final String DOCUMENTATION_TAG_RETURN
The documentation tag for result descriptions. Can be used alternatively toDOCUMENTATION_TAG_RESULT.- See Also:
- Constant Field Values
-
DOC_COMMENT_TOKENIZER_PATTERN
protected static final Pattern DOC_COMMENT_TOKENIZER_PATTERN
The pattern used to split documentation comments into elements.
-
-
Constructor Detail
-
ParsedDocumentationComment
public ParsedDocumentationComment(DocumentationComment aComment, ModelSourceInformationElement aModelSourceInfo) throws ParsedDocumentationComment.ParseException
Parses a givenDocumentationCommentand extracts the documentation info.- Parameters:
aComment- the comment element to be parsedaModelSourceInfo- the information about the source of the element, if available- Throws:
ParsedDocumentationComment.ParseException- in case of parsing errors
-
ParsedDocumentationComment
public ParsedDocumentationComment(DocumentationComment aComment, ModelSourceInformationElement aModelSourceInfo, boolean anAllowUnnamedResultsFlag) throws ParsedDocumentationComment.ParseException
Parses a givenDocumentationCommentand extracts the documentation info.- Parameters:
aComment- the comment element to be parsedaModelSourceInfo- the information about the source of the element, if availableanAllowUnnamedResultsFlag- whether to apply a heuristic in determining if we have an unnamed result (false = all results named)- Throws:
ParsedDocumentationComment.ParseException- in case of parsing errors
-
-
Method Detail
-
parse
protected void parse(String aCommentString, ModelSourceInformationElement aModelSourceInfo, boolean anAllowUnnamedResultsFlag) throws ParsedDocumentationComment.ParseException
Actually performs the heavy lifting.- Parameters:
aCommentString- the string to be parsed, right from the model elementaModelSourceInfo- the information about the source of the element, if availableanAllowUnnamedResultsFlag- whether to apply a heuristic in determining if we have an unnamed result (false = all results named)- Throws:
ParsedDocumentationComment.ParseException- in case of parsing errors
-
getOrigin
public DocumentationComment getOrigin()
-
getSourceInfo
public ModelSourceInformationElement getSourceInfo()
-
getRawText
public String getRawText()
-
getDocumentationText
public String getDocumentationText()
-
getDocumentationTextElements
public List<ParsedDocumentationComment.DocCommentElement> getDocumentationTextElements()
Lazily calculates the documentation text elements and returns them.- Returns:
-
getJavadocStyleFullDocumentation
public String getJavadocStyleFullDocumentation()
Generates a representation of this entire documentation comments' content in Javadoc-style HTML. This includes all known @ elements.- Returns:
-
getSortedParameterDocumentationTexts
public List<Map.Entry<String,String>> getSortedParameterDocumentationTexts()
-
getSortedResultDocumentationTexts
public List<Map.Entry<String,String>> getSortedResultDocumentationTexts()
-
addLines
protected static final ModelSourceInformationElement addLines(ModelSourceInformationElement anElement, int aNumberOfLines)
Clones the givenModelSourceInformationElementand adds a given number of lines to the line number of the provided element.- Parameters:
anElement- the base elementaNumberOfLines- the number of lines to add- Returns:
- a clone with a changed line number
-
tokenizeCommentText
protected List<ParsedDocumentationComment.DocCommentElement> tokenizeCommentText(String aText)
Splits the documentation comment text into elements.- Parameters:
aText-- Returns:
-
-