Class AbstractFixJavadocMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
    Direct Known Subclasses:
    FixJavadocMojo, TestFixJavadocMojo

    public abstract class AbstractFixJavadocMojo
    extends org.apache.maven.plugin.AbstractMojo
    Abstract class to fix Javadoc documentation and tags in source files.
    See Where Tags Can Be Used.
    Since:
    2.6
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String AUTHOR_TAG
      Tag name for @author *
      private static java.lang.String CLIRR_MAVEN_PLUGIN_ARTIFACTID
      The Clirr Maven plugin artifactId clirr-maven-plugin *
      private static java.lang.String CLIRR_MAVEN_PLUGIN_GOAL
      The Clirr Maven plugin goal check *
      private static java.lang.String CLIRR_MAVEN_PLUGIN_GROUPID
      The Clirr Maven plugin groupId org.codehaus.mojo *
      private static java.lang.String CLIRR_MAVEN_PLUGIN_VERSION
      The latest Clirr Maven plugin version 2.2.2 *
      private java.util.List<java.lang.String> clirrNewClasses
      New classes found by Clirr.
      private java.util.Map<java.lang.String,​java.util.List<java.lang.String>> clirrNewMethods
      New Methods in a Class (the key) found by Clirr.
      private java.lang.String comparisonVersion
      Version to compare the current code against using the Clirr Maven Plugin.
      static java.lang.String DEFAULT_VERSION_VALUE
      Default version value.
      private java.lang.String defaultAuthor
      Default value for the Javadoc tag @author.
      private java.lang.String defaultSince
      Default value for the Javadoc tag @since.
      private java.lang.String defaultVersion
      Default value for the Javadoc tag @version.
      private java.lang.String encoding
      The file encoding to use when reading the source files.
      private static java.lang.String END_JAVADOC
      End Javadoc String i.e.
      private static java.lang.String EOL
      The vm line separator
      private java.lang.String excludes
      Comma separated excludes Java files, i.e.
      private static java.lang.String FIX_TAGS_ALL
      all parameter used by fixTags *
      private boolean fixClassComment
      Flag to fix the classes or interfaces Javadoc comments according the level.
      private boolean fixFieldComment
      Flag to fix the fields Javadoc comments according the level.
      private boolean fixMethodComment
      Flag to fix the methods Javadoc comments according the level.
      private java.lang.String fixTags
      Comma separated tags to fix in classes, interfaces or methods Javadoc comments.
      private java.lang.String[] fixTagsSplitted
      Split fixTags by comma.
      private boolean force
      Forcing the goal execution i.e.
      protected boolean ignoreClirr
      Flag to ignore or not Clirr.
      private java.lang.String includes
      Comma separated includes Java files, i.e.
      private static java.lang.String INHERITED_JAVADOC
      Inherited Javadoc i.e.
      private static java.lang.String INHERITED_TAG
      Tag name for {@inheritDoc} *
      private org.codehaus.plexus.components.interactivity.InputHandler inputHandler
      Input handler, needed for command line handling.
      static java.lang.String JAVA_FILES
      Java Files Pattern.
      private java.lang.String level
      Specifies the access level for classes and members to show in the Javadocs.
      private static java.lang.String LEVEL_PACKAGE
      package parameter used by level *
      private static java.lang.String LEVEL_PRIVATE
      private parameter used by level *
      private static java.lang.String LEVEL_PROTECTED
      protected parameter used by level *
      private static java.lang.String LEVEL_PUBLIC
      public parameter used by level *
      private static java.lang.String LINK_TAG
      Tag name for @link *
      private org.apache.maven.artifact.repository.ArtifactRepository localRepository
      The local repository where the artifacts are located, used by the tests.
      private java.io.File outputDirectory
      Output directory where Java classes will be rewritten.
      private static java.lang.String PARAM_TAG
      Tag name for @param *
      private org.apache.maven.project.MavenProject project
      The Maven Project Object.
      private java.lang.ClassLoader projectClassLoader
      The current project class loader.
      private boolean removeUnknownThrows
      Flag to remove throws tags from unknown classes.
      private static java.lang.String RETURN_TAG
      Tag name for @return *
      private static java.lang.String SEPARATOR_JAVADOC
      Javadoc Separator i.e.
      private org.apache.maven.execution.MavenSession session  
      private org.apache.maven.settings.Settings settings
      The current user system settings for use in Maven.
      private static java.lang.String SINCE_TAG
      Tag name for @since *
      private java.util.List<java.lang.String> sinceClasses
      List of classes where *since is added.
      private static java.lang.String START_JAVADOC
      Start Javadoc String i.e.
      private static java.lang.String THROWS_TAG
      Tag name for @throws *
      private static java.lang.String VERSION_TAG
      Tag name for @version *
      • Fields inherited from interface org.apache.maven.plugin.Mojo

        ROLE
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void addDefaultClassComment​(java.io.StringWriter stringWriter, com.thoughtworks.qdox.model.JavaClass javaClass, java.lang.String indent)
      Add a default Javadoc for the given class, i.e.:
      1   /**
      2    * {Comment based on the class name}
      3    *
      4    @author  X {added if addMissingAuthor}
      5    @version  X {added if addMissingVersion}
      6    @since  X {added if addMissingSince and new classes from previous version}
      7    */
      8 public class  DummyClass {}
      private void addDefaultFieldComment​(java.io.StringWriter stringWriter, com.thoughtworks.qdox.model.JavaField field, java.lang.String indent)
      Add a default Javadoc for the given field, i.e.:
      1      /** Constant <code> MY_STRING_CONSTANT="value" </code> */
      2      public static final  String MY_STRING_CONSTANT =  "value";
      private void addDefaultJavadocComment​(java.lang.StringBuilder sb, com.thoughtworks.qdox.model.JavaAnnotatedElement entity, java.lang.String indent, boolean isJavaExecutable)  
      private void addDefaultJavadocTags​(java.lang.StringBuilder sb, com.thoughtworks.qdox.model.JavaAnnotatedElement entity, java.lang.String indent, boolean isJavaExecutable)  
      private void addDefaultMethodComment​(java.io.StringWriter stringWriter, com.thoughtworks.qdox.model.JavaExecutable javaExecutable, java.lang.String indent)
      Add in the buffer a default Javadoc for the given class:
      1   /**
      2    * {Comment based on the method name}
      3    *
      4    @param  X {added if addMissingParam}
      5    @return  X {added if addMissingReturn}
      6    @throws  X {added if addMissingThrows}
      7    @since  X {added if addMissingSince and new classes from previous version}
      8    */
      9 public  void dummyMethod String s  ){}
      private void addMissingJavadocTags​(java.lang.StringBuilder sb, com.thoughtworks.qdox.model.JavaAnnotatedElement entity, java.lang.String indent, boolean isJavaExecutable, AbstractFixJavadocMojo.JavaEntityTags javaEntityTags)
      Add missing tags not already written.
      private void addSinceClasses​(com.thoughtworks.qdox.model.JavaClass javaClass)  
      private static java.lang.String alignIndentationJavadocLines​(java.lang.String content, java.lang.String indent)  
      private void appendDefaultAuthorTag​(java.lang.StringBuilder sb, java.lang.String indent)  
      private boolean appendDefaultAuthorTag​(java.lang.StringBuilder sb, java.lang.String indent, boolean separatorAdded)  
      private boolean appendDefaultParamTag​(java.lang.StringBuilder sb, java.lang.String indent, boolean separatorAdded, com.thoughtworks.qdox.model.JavaParameter typeParam)  
      private boolean appendDefaultParamTag​(java.lang.StringBuilder sb, java.lang.String indent, boolean separatorAdded, com.thoughtworks.qdox.model.JavaTypeVariable<com.thoughtworks.qdox.model.JavaGenericDeclaration> typeParameter)  
      private void appendDefaultParamTag​(java.lang.StringBuilder sb, java.lang.String indent, com.thoughtworks.qdox.model.JavaParameter typeParam)  
      private void appendDefaultParamTag​(java.lang.StringBuilder sb, java.lang.String indent, com.thoughtworks.qdox.model.JavaTypeVariable<com.thoughtworks.qdox.model.JavaGenericDeclaration> typeParameter)  
      private boolean appendDefaultReturnTag​(java.lang.StringBuilder sb, java.lang.String indent, boolean separatorAdded, com.thoughtworks.qdox.model.JavaMethod javaMethod)  
      private void appendDefaultReturnTag​(java.lang.StringBuilder sb, java.lang.String indent, com.thoughtworks.qdox.model.JavaMethod javaMethod)  
      private void appendDefaultSinceTag​(java.lang.StringBuilder sb, java.lang.String indent)  
      private boolean appendDefaultSinceTag​(java.lang.StringBuilder sb, java.lang.String indent, boolean separatorAdded)  
      private boolean appendDefaultThrowsTag​(java.lang.StringBuilder sb, java.lang.String indent, boolean separatorAdded, com.thoughtworks.qdox.model.JavaType exception)  
      private void appendDefaultThrowsTag​(java.lang.StringBuilder sb, java.lang.String indent, com.thoughtworks.qdox.model.JavaType exception)  
      private void appendDefaultVersionTag​(java.lang.StringBuilder sb, java.lang.String indent)  
      private boolean appendDefaultVersionTag​(java.lang.StringBuilder sb, java.lang.String indent, boolean separatorAdded)  
      private void appendSeparator​(java.lang.StringBuilder sb, java.lang.String indent)  
      private static java.lang.String autodetectIndentation​(java.lang.String line)
      Autodetect the indentation of a given line:
      void execute()
      private void executeClirr()
      Invoke Maven to run clirr-maven-plugin to find API differences.
      (package private) static java.lang.String extractOriginalJavadoc​(java.lang.String javaClassContent, com.thoughtworks.qdox.model.JavaAnnotatedElement entity)
      Extract the original Javadoc and others comments up to START_JAVADOC form the entity.
      (package private) static java.lang.String extractOriginalJavadocContent​(java.lang.String javaClassContent, com.thoughtworks.qdox.model.JavaAnnotatedElement entity)
      Extract the Javadoc comment between START_JAVADOC and END_JAVADOC form the entity.
      private boolean fixClassComment​(java.io.StringWriter stringWriter, java.lang.String originalContent, com.thoughtworks.qdox.model.JavaClass javaClass, java.lang.String indent)
      Add/update Javadoc class comment.
      private boolean fixFieldComment​(java.io.StringWriter stringWriter, com.thoughtworks.qdox.model.JavaClass javaClass, com.thoughtworks.qdox.model.JavaField field, java.lang.String indent)
      Add Javadoc field comment, only for static fields or interface fields.
      private boolean fixMethodComment​(java.io.StringWriter stringWriter, java.lang.String originalContent, com.thoughtworks.qdox.model.JavaExecutable javaExecutable, java.lang.String indent)
      Add/update Javadoc method comment.
      private boolean fixTag​(java.lang.String tag)  
      protected java.lang.String getArtifactType​(org.apache.maven.project.MavenProject p)  
      private java.lang.Class<?> getClass​(com.thoughtworks.qdox.model.JavaClass currentClass, java.lang.String exceptionClassName)
      Returns the Class object assignable for RuntimeException class and associated with the given exception class name.
      private java.lang.Class<?> getClass​(java.lang.String className)  
      protected java.util.List<java.lang.String> getCompileClasspathElements​(org.apache.maven.project.MavenProject p)  
      private static java.lang.String getDefaultClassJavadocComment​(com.thoughtworks.qdox.model.JavaClass javaClass)
      Default comment for class.
      private java.lang.String getDefaultJavadocForType​(com.thoughtworks.qdox.model.JavaClass clazz)  
      private java.lang.String getDefaultJavadocForType​(com.thoughtworks.qdox.model.JavaTypeVariable<com.thoughtworks.qdox.model.JavaGenericDeclaration> typeParameter)  
      private static java.lang.String getDefaultMethodJavadocComment​(com.thoughtworks.qdox.model.JavaExecutable javaExecutable)
      Default comment for method with taking care of getter/setter in the javaMethod name.
      private static java.lang.String getFullClirrGoal()  
      (package private) static java.lang.String getJavadocComment​(java.lang.String javaClassContent, com.thoughtworks.qdox.model.JavaAnnotatedElement entity)
      Workaround for QDOX-146 about whitespace.
      (package private) java.lang.String getJavadocComment​(java.lang.String javaClassContent, com.thoughtworks.qdox.model.JavaAnnotatedElement entity, com.thoughtworks.qdox.model.DocletTag docletTag)
      Work around for QDOX-146 about whitespace.
      protected static java.lang.String getJavaMethodAsString​(com.thoughtworks.qdox.model.JavaExecutable javaExecutable)  
      private static java.lang.String[] getLines​(java.lang.String content)  
      protected org.apache.maven.project.MavenProject getProject()  
      private java.lang.ClassLoader getProjectClassLoader()  
      private java.io.File getProjectSourceDirectory()  
      protected java.util.List<java.lang.String> getProjectSourceRoots​(org.apache.maven.project.MavenProject p)  
      private java.util.Collection<com.thoughtworks.qdox.model.JavaClass> getQdoxClasses()
      Calling Qdox to find JavaClass objects from the Maven project sources.
      private static boolean hasInheritedTag​(java.lang.String content)
      Try to find if a Javadoc comment has an INHERITED_TAG for instance:
      private void init()
      Init goal parameters.
      private boolean isInherited​(com.thoughtworks.qdox.model.JavaExecutable javaMethod)
      Verify if a method has @java.lang.Override() annotation or if it is an inherited method from an interface or a super class.
      private boolean isInherited​(java.lang.Class<?> clazz, com.thoughtworks.qdox.model.JavaExecutable javaMethod)  
      private boolean isInLevel​(java.util.List<java.lang.String> modifiers)  
      private boolean isNewClassFromLastVersion​(com.thoughtworks.qdox.model.JavaClass javaClass)
      Check under Clirr if this given class is newer from the last version.
      private boolean isNewMethodFromLastRevision​(com.thoughtworks.qdox.model.JavaExecutable javaExecutable)
      Check under Clirr if this given method is newer from the last version.
      private void parseClirrTextOutputFile​(java.io.File clirrTextOutputFile)  
      (package private) AbstractFixJavadocMojo.JavaEntityTags parseJavadocTags​(java.lang.String originalContent, com.thoughtworks.qdox.model.JavaAnnotatedElement entity, java.lang.String indent, boolean isJavaMethod)
      Parse entity tags
      private boolean preCheck()  
      private void processFix​(com.thoughtworks.qdox.model.JavaClass javaClass)
      Process the given JavaClass, ie add missing javadoc tags depending user parameters.
      private static java.lang.String removeLastEmptyJavadocLines​(java.lang.String content)  
      (package private) static java.lang.String replaceLinkTags​(java.lang.String comment, com.thoughtworks.qdox.model.JavaAnnotatedElement entity)  
      private boolean sinceClassesContains​(com.thoughtworks.qdox.model.JavaClass javaClass)  
      private void takeCareSingleComment​(java.io.StringWriter stringWriter, java.lang.String originalContent, com.thoughtworks.qdox.model.JavaAnnotatedElement entity)
      Take care of block or single comments between Javadoc comment and entity declaration ie:
      1   /**
      2    * {Javadoc Comment}
      3    */
      4   /*
      5    * {Block Comment}
      6    */
      7   // {Single comment}
      8   public void  dummyMethod String s ){}
      private static java.lang.String trimLeft​(java.lang.String text)
      Trim a given line on the left:
      private static java.lang.String trimRight​(java.lang.String text)
      Trim a given line on the right:
      private boolean updateEntityComment​(java.io.StringWriter stringWriter, java.lang.String originalContent, com.thoughtworks.qdox.model.JavaAnnotatedElement entity, java.lang.String indent)  
      private void updateJavadocComment​(java.io.StringWriter stringWriter, java.lang.String originalContent, com.thoughtworks.qdox.model.JavaAnnotatedElement entity, java.lang.String indent)  
      private void updateJavadocComment​(java.lang.StringBuilder sb, java.lang.String originalContent, com.thoughtworks.qdox.model.JavaAnnotatedElement entity, java.lang.String indent)  
      private void updateJavadocTags​(java.lang.StringBuilder sb, com.thoughtworks.qdox.model.JavaAnnotatedElement entity, boolean isJavaExecutable, AbstractFixJavadocMojo.JavaEntityTags javaEntityTags)
      Write tags according javaEntityTags.
      private void updateJavadocTags​(java.lang.StringBuilder sb, java.lang.String originalContent, com.thoughtworks.qdox.model.JavaAnnotatedElement entity, java.lang.String indent, boolean isJavaExecutable)  
      private static void writeFile​(java.io.File javaFile, java.lang.String encoding, java.lang.String content)
      Write content into the given javaFile and using the given encoding.
      private void writeParamTag​(java.lang.StringBuilder sb, com.thoughtworks.qdox.model.JavaExecutable javaExecutable, AbstractFixJavadocMojo.JavaEntityTags javaEntityTags, java.lang.String paramName, java.lang.String paramValue)  
      private void writeReturnTag​(java.lang.StringBuilder sb, com.thoughtworks.qdox.model.JavaMethod javaMethod, AbstractFixJavadocMojo.JavaEntityTags javaEntityTags)  
      (package private) void writeThrowsTag​(java.lang.StringBuilder sb, com.thoughtworks.qdox.model.JavaExecutable javaExecutable, AbstractFixJavadocMojo.JavaEntityTags javaEntityTags, java.util.List<java.lang.String> params)  
      • Methods inherited from class org.apache.maven.plugin.AbstractMojo

        getLog, getPluginContext, setLog, setPluginContext
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • EOL

        private static final java.lang.String EOL
        The vm line separator
      • AUTHOR_TAG

        private static final java.lang.String AUTHOR_TAG
        Tag name for @author *
        See Also:
        Constant Field Values
      • VERSION_TAG

        private static final java.lang.String VERSION_TAG
        Tag name for @version *
        See Also:
        Constant Field Values
      • SINCE_TAG

        private static final java.lang.String SINCE_TAG
        Tag name for @since *
        See Also:
        Constant Field Values
      • PARAM_TAG

        private static final java.lang.String PARAM_TAG
        Tag name for @param *
        See Also:
        Constant Field Values
      • RETURN_TAG

        private static final java.lang.String RETURN_TAG
        Tag name for @return *
        See Also:
        Constant Field Values
      • THROWS_TAG

        private static final java.lang.String THROWS_TAG
        Tag name for @throws *
        See Also:
        Constant Field Values
      • LINK_TAG

        private static final java.lang.String LINK_TAG
        Tag name for @link *
        See Also:
        Constant Field Values
      • INHERITED_TAG

        private static final java.lang.String INHERITED_TAG
        Tag name for {@inheritDoc} *
        See Also:
        Constant Field Values
      • START_JAVADOC

        private static final java.lang.String START_JAVADOC
        Start Javadoc String i.e. /** *
        See Also:
        Constant Field Values
      • END_JAVADOC

        private static final java.lang.String END_JAVADOC
        End Javadoc String i.e. */ *
        See Also:
        Constant Field Values
      • SEPARATOR_JAVADOC

        private static final java.lang.String SEPARATOR_JAVADOC
        Javadoc Separator i.e. * *
        See Also:
        Constant Field Values
      • INHERITED_JAVADOC

        private static final java.lang.String INHERITED_JAVADOC
        Inherited Javadoc i.e. /** {@inheritDoc} */ *
        See Also:
        Constant Field Values
      • LEVEL_PUBLIC

        private static final java.lang.String LEVEL_PUBLIC
        public parameter used by level *
        See Also:
        Constant Field Values
      • LEVEL_PROTECTED

        private static final java.lang.String LEVEL_PROTECTED
        protected parameter used by level *
        See Also:
        Constant Field Values
      • LEVEL_PACKAGE

        private static final java.lang.String LEVEL_PACKAGE
        package parameter used by level *
        See Also:
        Constant Field Values
      • LEVEL_PRIVATE

        private static final java.lang.String LEVEL_PRIVATE
        private parameter used by level *
        See Also:
        Constant Field Values
      • CLIRR_MAVEN_PLUGIN_GROUPID

        private static final java.lang.String CLIRR_MAVEN_PLUGIN_GROUPID
        The Clirr Maven plugin groupId org.codehaus.mojo *
        See Also:
        Constant Field Values
      • CLIRR_MAVEN_PLUGIN_ARTIFACTID

        private static final java.lang.String CLIRR_MAVEN_PLUGIN_ARTIFACTID
        The Clirr Maven plugin artifactId clirr-maven-plugin *
        See Also:
        Constant Field Values
      • CLIRR_MAVEN_PLUGIN_VERSION

        private static final java.lang.String CLIRR_MAVEN_PLUGIN_VERSION
        The latest Clirr Maven plugin version 2.2.2 *
        See Also:
        Constant Field Values
      • CLIRR_MAVEN_PLUGIN_GOAL

        private static final java.lang.String CLIRR_MAVEN_PLUGIN_GOAL
        The Clirr Maven plugin goal check *
        See Also:
        Constant Field Values
      • JAVA_FILES

        public static final java.lang.String JAVA_FILES
        Java Files Pattern.
        See Also:
        Constant Field Values
      • DEFAULT_VERSION_VALUE

        public static final java.lang.String DEFAULT_VERSION_VALUE
        Default version value.
        See Also:
        Constant Field Values
      • inputHandler

        @Component
        private org.codehaus.plexus.components.interactivity.InputHandler inputHandler
        Input handler, needed for command line handling.
      • comparisonVersion

        @Parameter(property="comparisonVersion",
                   defaultValue="(,${project.version})")
        private java.lang.String comparisonVersion
        Version to compare the current code against using the Clirr Maven Plugin.
        See defaultSince.
      • defaultAuthor

        @Parameter(property="defaultAuthor")
        private java.lang.String defaultAuthor
        Default value for the Javadoc tag @author.
        If not specified, the user.name defined in the System properties will be used.
      • defaultSince

        @Parameter(property="defaultSince",
                   defaultValue="${project.version}")
        private java.lang.String defaultSince
        Default value for the Javadoc tag @since.
      • defaultVersion

        @Parameter(property="defaultVersion",
                   defaultValue="$Id: $Id")
        private java.lang.String defaultVersion
        Default value for the Javadoc tag @version.
        By default, it is $Id:$, corresponding to a SVN keyword. Refer to your SCM to use an other SCM keyword.
      • encoding

        @Parameter(property="encoding",
                   defaultValue="${project.build.sourceEncoding}")
        private java.lang.String encoding
        The file encoding to use when reading the source files. If the property project.build.sourceEncoding is not set, the platform default encoding is used.
      • excludes

        @Parameter(property="excludes")
        private java.lang.String excludes
        Comma separated excludes Java files, i.e. **/*Test.java.
      • fixTags

        @Parameter(property="fixTags",
                   defaultValue="all")
        private java.lang.String fixTags
        Comma separated tags to fix in classes, interfaces or methods Javadoc comments. Possible values are:
        • all (fix all Javadoc tags)
        • author (fix only @author tag)
        • version (fix only @version tag)
        • since (fix only @since tag)
        • param (fix only @param tag)
        • return (fix only @return tag)
        • throws (fix only @throws tag)
        • link (fix only @link tag)
      • fixClassComment

        @Parameter(property="fixClassComment",
                   defaultValue="true")
        private boolean fixClassComment
        Flag to fix the classes or interfaces Javadoc comments according the level.
      • fixFieldComment

        @Parameter(property="fixFieldComment",
                   defaultValue="true")
        private boolean fixFieldComment
        Flag to fix the fields Javadoc comments according the level.
      • fixMethodComment

        @Parameter(property="fixMethodComment",
                   defaultValue="true")
        private boolean fixMethodComment
        Flag to fix the methods Javadoc comments according the level.
      • removeUnknownThrows

        @Parameter(property="removeUnknownThrows",
                   defaultValue="true")
        private boolean removeUnknownThrows

        Flag to remove throws tags from unknown classes.

        NOTE:Since 3.1.0 the default value has been changed to true, due to JavaDoc 8 strictness.

      • force

        @Parameter(property="force")
        private boolean force
        Forcing the goal execution i.e. skip warranty messages (not recommended).
      • ignoreClirr

        @Parameter(property="ignoreClirr",
                   defaultValue="false")
        protected boolean ignoreClirr
        Flag to ignore or not Clirr.
      • includes

        @Parameter(property="includes",
                   defaultValue="**\\/*.java")
        private java.lang.String includes
        Comma separated includes Java files, i.e. **/*Test.java.

        Note: default value is **\/*.java.

      • level

        @Parameter(property="level",
                   defaultValue="protected")
        private java.lang.String level
        Specifies the access level for classes and members to show in the Javadocs. Possible values are:
        • public (shows only public classes and members)
        • protected (shows only public and protected classes and members)
        • package (shows all classes and members not marked private)
        • private (shows all classes and members)
      • localRepository

        @Parameter(property="localRepository")
        private org.apache.maven.artifact.repository.ArtifactRepository localRepository
        The local repository where the artifacts are located, used by the tests.
      • outputDirectory

        @Parameter(property="outputDirectory",
                   defaultValue="${project.build.sourceDirectory}")
        private java.io.File outputDirectory
        Output directory where Java classes will be rewritten.
      • project

        @Parameter(defaultValue="${project}",
                   readonly=true,
                   required=true)
        private org.apache.maven.project.MavenProject project
        The Maven Project Object.
      • session

        @Parameter(defaultValue="${session}",
                   readonly=true,
                   required=true)
        private org.apache.maven.execution.MavenSession session
      • settings

        @Parameter(defaultValue="${settings}",
                   readonly=true,
                   required=true)
        private org.apache.maven.settings.Settings settings
        The current user system settings for use in Maven.
      • projectClassLoader

        private java.lang.ClassLoader projectClassLoader
        The current project class loader.
      • fixTagsSplitted

        private java.lang.String[] fixTagsSplitted
        Split fixTags by comma.
        See Also:
        init()
      • clirrNewClasses

        private java.util.List<java.lang.String> clirrNewClasses
        New classes found by Clirr.
      • clirrNewMethods

        private java.util.Map<java.lang.String,​java.util.List<java.lang.String>> clirrNewMethods
        New Methods in a Class (the key) found by Clirr.
      • sinceClasses

        private java.util.List<java.lang.String> sinceClasses
        List of classes where *since is added. Will be used to add or not this tag in the methods.
    • Constructor Detail

      • AbstractFixJavadocMojo

        public AbstractFixJavadocMojo()
    • Method Detail

      • execute

        public void execute()
                     throws org.apache.maven.plugin.MojoExecutionException,
                            org.apache.maven.plugin.MojoFailureException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
        org.apache.maven.plugin.MojoFailureException
      • getProject

        protected final org.apache.maven.project.MavenProject getProject()
      • getArtifactType

        protected java.lang.String getArtifactType​(org.apache.maven.project.MavenProject p)
        Parameters:
        p - not null maven project.
        Returns:
        the artifact type.
      • getProjectSourceRoots

        protected java.util.List<java.lang.String> getProjectSourceRoots​(org.apache.maven.project.MavenProject p)
        Parameters:
        p - not null maven project.
        Returns:
        the list of source paths for the given project.
      • getCompileClasspathElements

        protected java.util.List<java.lang.String> getCompileClasspathElements​(org.apache.maven.project.MavenProject p)
                                                                        throws org.apache.maven.artifact.DependencyResolutionRequiredException
        Parameters:
        p - not null
        Returns:
        the compile classpath elements
        Throws:
        org.apache.maven.artifact.DependencyResolutionRequiredException - if any
      • getJavaMethodAsString

        protected static java.lang.String getJavaMethodAsString​(com.thoughtworks.qdox.model.JavaExecutable javaExecutable)
        Parameters:
        javaExecutable - not null
        Returns:
        the fully qualify name of javaMethod with signature
      • init

        private void init()
        Init goal parameters.
      • preCheck

        private boolean preCheck()
                          throws org.apache.maven.plugin.MojoExecutionException
        Returns:
        true if the user wants to proceed, false otherwise.
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if any
      • getProjectSourceDirectory

        private java.io.File getProjectSourceDirectory()
        Returns:
        the source dir as File for the given project
      • executeClirr

        private void executeClirr()
                           throws org.apache.maven.shared.invoker.MavenInvocationException
        Invoke Maven to run clirr-maven-plugin to find API differences.
        Throws:
        org.apache.maven.shared.invoker.MavenInvocationException - if any
      • parseClirrTextOutputFile

        private void parseClirrTextOutputFile​(java.io.File clirrTextOutputFile)
                                       throws java.io.IOException
        Parameters:
        clirrTextOutputFile - not null
        Throws:
        java.io.IOException - if any
      • fixTag

        private boolean fixTag​(java.lang.String tag)
        Parameters:
        tag - not null
        Returns:
        true if tag is defined in fixTags.
      • getQdoxClasses

        private java.util.Collection<com.thoughtworks.qdox.model.JavaClass> getQdoxClasses()
                                                                                    throws java.io.IOException,
                                                                                           org.apache.maven.plugin.MojoExecutionException
        Calling Qdox to find JavaClass objects from the Maven project sources. Ignore java class if Qdox has parsing errors.
        Returns:
        an array of JavaClass found by QDox
        Throws:
        java.io.IOException - if any
        org.apache.maven.plugin.MojoExecutionException - if any
      • getProjectClassLoader

        private java.lang.ClassLoader getProjectClassLoader()
                                                     throws org.apache.maven.plugin.MojoExecutionException
        Returns:
        the classLoader for the given project using lazy instantiation.
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if any
      • processFix

        private void processFix​(com.thoughtworks.qdox.model.JavaClass javaClass)
                         throws java.io.IOException,
                                org.apache.maven.plugin.MojoExecutionException
        Process the given JavaClass, ie add missing javadoc tags depending user parameters.
        Parameters:
        javaClass - not null
        Throws:
        java.io.IOException - if any
        org.apache.maven.plugin.MojoExecutionException - if any
      • takeCareSingleComment

        private void takeCareSingleComment​(java.io.StringWriter stringWriter,
                                           java.lang.String originalContent,
                                           com.thoughtworks.qdox.model.JavaAnnotatedElement entity)
                                    throws java.io.IOException
        Take care of block or single comments between Javadoc comment and entity declaration ie:
        1   /**
        2    * {Javadoc Comment}
        3    */
        4   /*
        5    * {Block Comment}
        6    */
        7   // {Single comment}
        8   public void  dummyMethod String s ){}
        Parameters:
        stringWriter - not null
        originalContent - not null
        entity - not null
        Throws:
        java.io.IOException - if any
        See Also:
        extractOriginalJavadoc(java.lang.String, com.thoughtworks.qdox.model.JavaAnnotatedElement)
      • fixClassComment

        private boolean fixClassComment​(java.io.StringWriter stringWriter,
                                        java.lang.String originalContent,
                                        com.thoughtworks.qdox.model.JavaClass javaClass,
                                        java.lang.String indent)
                                 throws org.apache.maven.plugin.MojoExecutionException,
                                        java.io.IOException
        Add/update Javadoc class comment.
        Parameters:
        stringWriter -
        originalContent -
        javaClass -
        indent -
        Returns:
        true if the comment is updated, otherwise false
        Throws:
        org.apache.maven.plugin.MojoExecutionException
        java.io.IOException
      • isInLevel

        private boolean isInLevel​(java.util.List<java.lang.String> modifiers)
        Parameters:
        modifiers - list of modifiers (public, private, protected, package)
        Returns:
        true if modifier is align with level.
      • fixFieldComment

        private boolean fixFieldComment​(java.io.StringWriter stringWriter,
                                        com.thoughtworks.qdox.model.JavaClass javaClass,
                                        com.thoughtworks.qdox.model.JavaField field,
                                        java.lang.String indent)
                                 throws java.io.IOException
        Add Javadoc field comment, only for static fields or interface fields.
        Parameters:
        stringWriter - not null
        javaClass - not null
        field - not null
        indent - not null
        Returns:
        true if comment was updated, otherwise false
        Throws:
        java.io.IOException - if any
      • addDefaultFieldComment

        private void addDefaultFieldComment​(java.io.StringWriter stringWriter,
                                            com.thoughtworks.qdox.model.JavaField field,
                                            java.lang.String indent)
                                     throws java.io.IOException
        Add a default Javadoc for the given field, i.e.:
        1      /** Constant <code> MY_STRING_CONSTANT="value" </code> */
        2      public static final  String MY_STRING_CONSTANT =  "value";
        Parameters:
        stringWriter - not null
        field - not null
        indent - not null
        Throws:
        java.io.IOException - if any
      • fixMethodComment

        private boolean fixMethodComment​(java.io.StringWriter stringWriter,
                                         java.lang.String originalContent,
                                         com.thoughtworks.qdox.model.JavaExecutable javaExecutable,
                                         java.lang.String indent)
                                  throws org.apache.maven.plugin.MojoExecutionException,
                                         java.io.IOException
        Add/update Javadoc method comment.
        Parameters:
        stringWriter - not null
        originalContent - not null
        javaExecutable - not null
        indent - not null
        Returns:
        true if comment was updated, otherwise false
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if any
        java.io.IOException - if any
      • addDefaultMethodComment

        private void addDefaultMethodComment​(java.io.StringWriter stringWriter,
                                             com.thoughtworks.qdox.model.JavaExecutable javaExecutable,
                                             java.lang.String indent)
                                      throws org.apache.maven.plugin.MojoExecutionException
        Add in the buffer a default Javadoc for the given class:
        1   /**
        2    * {Comment based on the method name}
        3    *
        4    @param  X {added if addMissingParam}
        5    @return  X {added if addMissingReturn}
        6    @throws  X {added if addMissingThrows}
        7    @since  X {added if addMissingSince and new classes from previous version}
        8    */
        9 public  void dummyMethod String s  ){}
        Parameters:
        stringWriter - not null
        javaExecutable - not null
        indent - not null
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if any
        See Also:
        getDefaultMethodJavadocComment(com.thoughtworks.qdox.model.JavaExecutable), appendDefaultSinceTag(StringBuilder, String)
      • updateEntityComment

        private boolean updateEntityComment​(java.io.StringWriter stringWriter,
                                            java.lang.String originalContent,
                                            com.thoughtworks.qdox.model.JavaAnnotatedElement entity,
                                            java.lang.String indent)
                                     throws org.apache.maven.plugin.MojoExecutionException,
                                            java.io.IOException
        Parameters:
        stringWriter - not null
        originalContent - not null
        entity - not null
        indent - not null
        Returns:
        the updated changeDetected flag
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if any
        java.io.IOException - if any
      • updateJavadocComment

        private void updateJavadocComment​(java.io.StringWriter stringWriter,
                                          java.lang.String originalContent,
                                          com.thoughtworks.qdox.model.JavaAnnotatedElement entity,
                                          java.lang.String indent)
                                   throws org.apache.maven.plugin.MojoExecutionException,
                                          java.io.IOException
        Parameters:
        stringWriter - not null
        originalContent - not null
        entity - not null
        indent - not null
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if any
        java.io.IOException - if any
      • updateJavadocComment

        private void updateJavadocComment​(java.lang.StringBuilder sb,
                                          java.lang.String originalContent,
                                          com.thoughtworks.qdox.model.JavaAnnotatedElement entity,
                                          java.lang.String indent)
                                   throws java.io.IOException
        Parameters:
        sb - not null
        originalContent - not null
        entity - not null
        indent - not null
        Throws:
        java.io.IOException - if any
      • replaceLinkTags

        static java.lang.String replaceLinkTags​(java.lang.String comment,
                                                com.thoughtworks.qdox.model.JavaAnnotatedElement entity)
      • addDefaultJavadocComment

        private void addDefaultJavadocComment​(java.lang.StringBuilder sb,
                                              com.thoughtworks.qdox.model.JavaAnnotatedElement entity,
                                              java.lang.String indent,
                                              boolean isJavaExecutable)
        Parameters:
        sb - not null
        entity - not null
        indent - not null
        isJavaExecutable -
      • updateJavadocTags

        private void updateJavadocTags​(java.lang.StringBuilder sb,
                                       java.lang.String originalContent,
                                       com.thoughtworks.qdox.model.JavaAnnotatedElement entity,
                                       java.lang.String indent,
                                       boolean isJavaExecutable)
                                throws java.io.IOException,
                                       org.apache.maven.plugin.MojoExecutionException
        Parameters:
        sb - not null
        originalContent - not null
        entity - not null
        indent - not null
        isJavaExecutable -
        Throws:
        java.io.IOException - if any
        org.apache.maven.plugin.MojoExecutionException - if any
      • parseJavadocTags

        AbstractFixJavadocMojo.JavaEntityTags parseJavadocTags​(java.lang.String originalContent,
                                                               com.thoughtworks.qdox.model.JavaAnnotatedElement entity,
                                                               java.lang.String indent,
                                                               boolean isJavaMethod)
                                                        throws java.io.IOException
        Parse entity tags
        Parameters:
        originalContent - not null
        entity - not null
        indent - not null
        isJavaMethod -
        Returns:
        an instance of AbstractFixJavadocMojo.JavaEntityTags
        Throws:
        java.io.IOException - if any
      • updateJavadocTags

        private void updateJavadocTags​(java.lang.StringBuilder sb,
                                       com.thoughtworks.qdox.model.JavaAnnotatedElement entity,
                                       boolean isJavaExecutable,
                                       AbstractFixJavadocMojo.JavaEntityTags javaEntityTags)
        Write tags according javaEntityTags.
        Parameters:
        sb - not null
        entity - not null
        isJavaExecutable -
        javaEntityTags - not null
      • writeParamTag

        private void writeParamTag​(java.lang.StringBuilder sb,
                                   com.thoughtworks.qdox.model.JavaExecutable javaExecutable,
                                   AbstractFixJavadocMojo.JavaEntityTags javaEntityTags,
                                   java.lang.String paramName,
                                   java.lang.String paramValue)
      • writeReturnTag

        private void writeReturnTag​(java.lang.StringBuilder sb,
                                    com.thoughtworks.qdox.model.JavaMethod javaMethod,
                                    AbstractFixJavadocMojo.JavaEntityTags javaEntityTags)
      • writeThrowsTag

        void writeThrowsTag​(java.lang.StringBuilder sb,
                            com.thoughtworks.qdox.model.JavaExecutable javaExecutable,
                            AbstractFixJavadocMojo.JavaEntityTags javaEntityTags,
                            java.util.List<java.lang.String> params)
      • addMissingJavadocTags

        private void addMissingJavadocTags​(java.lang.StringBuilder sb,
                                           com.thoughtworks.qdox.model.JavaAnnotatedElement entity,
                                           java.lang.String indent,
                                           boolean isJavaExecutable,
                                           AbstractFixJavadocMojo.JavaEntityTags javaEntityTags)
                                    throws org.apache.maven.plugin.MojoExecutionException
        Add missing tags not already written.
        Parameters:
        sb - not null
        entity - not null
        indent - not null
        isJavaExecutable -
        javaEntityTags - not null
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if any
      • addDefaultJavadocTags

        private void addDefaultJavadocTags​(java.lang.StringBuilder sb,
                                           com.thoughtworks.qdox.model.JavaAnnotatedElement entity,
                                           java.lang.String indent,
                                           boolean isJavaExecutable)
                                    throws org.apache.maven.plugin.MojoExecutionException
        Parameters:
        sb - not null
        entity - not null
        indent - not null
        isJavaExecutable -
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if any
      • appendDefaultAuthorTag

        private boolean appendDefaultAuthorTag​(java.lang.StringBuilder sb,
                                               java.lang.String indent,
                                               boolean separatorAdded)
        Parameters:
        sb - not null
        indent - not null
        separatorAdded -
        Returns:
        true if separator has been added.
      • appendDefaultAuthorTag

        private void appendDefaultAuthorTag​(java.lang.StringBuilder sb,
                                            java.lang.String indent)
        Parameters:
        sb - not null
        indent - not null
      • appendDefaultSinceTag

        private boolean appendDefaultSinceTag​(java.lang.StringBuilder sb,
                                              java.lang.String indent,
                                              boolean separatorAdded)
        Parameters:
        sb - not null
        indent - not null
        separatorAdded -
        Returns:
        true if separator has been added.
      • appendDefaultSinceTag

        private void appendDefaultSinceTag​(java.lang.StringBuilder sb,
                                           java.lang.String indent)
        Parameters:
        sb - not null
        indent - not null
      • appendDefaultVersionTag

        private boolean appendDefaultVersionTag​(java.lang.StringBuilder sb,
                                                java.lang.String indent,
                                                boolean separatorAdded)
        Parameters:
        sb - not null
        indent - not null
        separatorAdded -
        Returns:
        true if separator has been added.
      • appendDefaultVersionTag

        private void appendDefaultVersionTag​(java.lang.StringBuilder sb,
                                             java.lang.String indent)
        Parameters:
        sb - not null
        indent - not null
      • appendDefaultParamTag

        private boolean appendDefaultParamTag​(java.lang.StringBuilder sb,
                                              java.lang.String indent,
                                              boolean separatorAdded,
                                              com.thoughtworks.qdox.model.JavaParameter typeParam)
        Parameters:
        sb - not null
        indent - not null
        separatorAdded -
        typeParam - not null
        Returns:
        true if separator has been added.
      • appendDefaultParamTag

        private boolean appendDefaultParamTag​(java.lang.StringBuilder sb,
                                              java.lang.String indent,
                                              boolean separatorAdded,
                                              com.thoughtworks.qdox.model.JavaTypeVariable<com.thoughtworks.qdox.model.JavaGenericDeclaration> typeParameter)
        Parameters:
        sb - not null
        indent - not null
        separatorAdded -
        typeParameter - not null
        Returns:
        true if separator has been added.
      • appendDefaultParamTag

        private void appendDefaultParamTag​(java.lang.StringBuilder sb,
                                           java.lang.String indent,
                                           com.thoughtworks.qdox.model.JavaParameter typeParam)
        Parameters:
        sb - not null
        indent - not null
        typeParam - not null
      • appendDefaultParamTag

        private void appendDefaultParamTag​(java.lang.StringBuilder sb,
                                           java.lang.String indent,
                                           com.thoughtworks.qdox.model.JavaTypeVariable<com.thoughtworks.qdox.model.JavaGenericDeclaration> typeParameter)
        Parameters:
        sb - not null
        indent - not null
        typeParameter - not null
      • appendDefaultReturnTag

        private boolean appendDefaultReturnTag​(java.lang.StringBuilder sb,
                                               java.lang.String indent,
                                               boolean separatorAdded,
                                               com.thoughtworks.qdox.model.JavaMethod javaMethod)
        Parameters:
        sb - not null
        indent - not null
        separatorAdded -
        javaMethod - not null
        Returns:
        true if separator has been added.
      • appendDefaultReturnTag

        private void appendDefaultReturnTag​(java.lang.StringBuilder sb,
                                            java.lang.String indent,
                                            com.thoughtworks.qdox.model.JavaMethod javaMethod)
        Parameters:
        sb - not null
        indent - not null
        javaMethod - not null
      • appendDefaultThrowsTag

        private boolean appendDefaultThrowsTag​(java.lang.StringBuilder sb,
                                               java.lang.String indent,
                                               boolean separatorAdded,
                                               com.thoughtworks.qdox.model.JavaType exception)
        Parameters:
        sb - not null
        indent - not null
        separatorAdded -
        exception - not null
        Returns:
        true if separator has been added.
      • appendDefaultThrowsTag

        private void appendDefaultThrowsTag​(java.lang.StringBuilder sb,
                                            java.lang.String indent,
                                            com.thoughtworks.qdox.model.JavaType exception)
        Parameters:
        sb - not null
        indent - not null
        exception - not null
      • appendSeparator

        private void appendSeparator​(java.lang.StringBuilder sb,
                                     java.lang.String indent)
        Parameters:
        sb - not null
        indent - not null
      • isInherited

        private boolean isInherited​(com.thoughtworks.qdox.model.JavaExecutable javaMethod)
                             throws org.apache.maven.plugin.MojoExecutionException
        Verify if a method has @java.lang.Override() annotation or if it is an inherited method from an interface or a super class. The goal is to handle {@inheritDoc} tag.
        Parameters:
        javaMethod - not null
        Returns:
        true if the method is inherited, false otherwise.
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if any
      • isInherited

        private boolean isInherited​(java.lang.Class<?> clazz,
                                    com.thoughtworks.qdox.model.JavaExecutable javaMethod)
        Parameters:
        clazz - the Java class object, not null
        javaMethod - the QDox JavaMethod object not null
        Returns:
        true if javaMethod exists in the given clazz, false otherwise.
        See Also:
        isInherited(JavaExecutable)
      • getDefaultJavadocForType

        private java.lang.String getDefaultJavadocForType​(com.thoughtworks.qdox.model.JavaClass clazz)
        Parameters:
        clazz -
        Returns:
      • getDefaultJavadocForType

        private java.lang.String getDefaultJavadocForType​(com.thoughtworks.qdox.model.JavaTypeVariable<com.thoughtworks.qdox.model.JavaGenericDeclaration> typeParameter)
      • isNewClassFromLastVersion

        private boolean isNewClassFromLastVersion​(com.thoughtworks.qdox.model.JavaClass javaClass)
        Check under Clirr if this given class is newer from the last version.
        Parameters:
        javaClass - a given class not null
        Returns:
        true if Clirr said that this class is added from the last version, false otherwise or if clirrNewClasses is null.
      • isNewMethodFromLastRevision

        private boolean isNewMethodFromLastRevision​(com.thoughtworks.qdox.model.JavaExecutable javaExecutable)
                                             throws org.apache.maven.plugin.MojoExecutionException
        Check under Clirr if this given method is newer from the last version.
        Parameters:
        javaExecutable - a given method not null
        Returns:
        true if Clirr said that this method is added from the last version, false otherwise or if clirrNewMethods is null.
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if any
      • getClass

        private java.lang.Class<?> getClass​(java.lang.String className)
                                     throws org.apache.maven.plugin.MojoExecutionException
        Parameters:
        className - not null
        Returns:
        the Class corresponding to the given class name using the project classloader.
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if class not found
        See Also:
        ClassUtils.getClass(ClassLoader, String, boolean), getProjectClassLoader()
      • getClass

        private java.lang.Class<?> getClass​(com.thoughtworks.qdox.model.JavaClass currentClass,
                                            java.lang.String exceptionClassName)
        Returns the Class object assignable for RuntimeException class and associated with the given exception class name.
        Parameters:
        currentClass - not null
        exceptionClassName - not null, an exception class name defined as:
        • exception class fully qualified
        • exception class in the same package
        • exception inner class
        • exception class in java.lang package
        Returns:
        the class if found, otherwise null.
        See Also:
        getClass(String)
      • addSinceClasses

        private void addSinceClasses​(com.thoughtworks.qdox.model.JavaClass javaClass)
        Parameters:
        javaClass - not null
      • sinceClassesContains

        private boolean sinceClassesContains​(com.thoughtworks.qdox.model.JavaClass javaClass)
      • writeFile

        private static void writeFile​(java.io.File javaFile,
                                      java.lang.String encoding,
                                      java.lang.String content)
                               throws java.io.IOException
        Write content into the given javaFile and using the given encoding. All line separators will be unified.
        Parameters:
        javaFile - not null
        encoding - not null
        content - not null
        Throws:
        java.io.IOException - if any
      • getFullClirrGoal

        private static java.lang.String getFullClirrGoal()
        Returns:
        the full clirr goal, i.e. groupId:artifactId:version:goal. The clirr-plugin version could be load from the pom.properties in the clirr-maven-plugin dependency.
      • getDefaultClassJavadocComment

        private static java.lang.String getDefaultClassJavadocComment​(com.thoughtworks.qdox.model.JavaClass javaClass)
        Default comment for class.
        Parameters:
        javaClass - not null
        Returns:
        a default comment for class.
      • getDefaultMethodJavadocComment

        private static java.lang.String getDefaultMethodJavadocComment​(com.thoughtworks.qdox.model.JavaExecutable javaExecutable)
        Default comment for method with taking care of getter/setter in the javaMethod name.
        Parameters:
        javaExecutable - not null
        Returns:
        a default comment for method.
      • hasInheritedTag

        private static boolean hasInheritedTag​(java.lang.String content)
        Try to find if a Javadoc comment has an INHERITED_TAG for instance:
         /** {@inheritDoc} */
         
        or
         /**
          * {@inheritDoc}
          */
         
        Parameters:
        content - not null
        Returns:
        true if the content has an inherited tag, false otherwise.
      • getJavadocComment

        static java.lang.String getJavadocComment​(java.lang.String javaClassContent,
                                                  com.thoughtworks.qdox.model.JavaAnnotatedElement entity)
                                           throws java.io.IOException
        Workaround for QDOX-146 about whitespace. Ideally we want to use entity.getComment()
        For instance, with the following snippet:

        1 
        2      /**
        3       * Dummy Javadoc comment.
        4       @param  s a String
        5       */
        6      public void  dummyMethod String s ){}


        The return will be:

        1       * Dummy Javadoc comment.

        Parameters:
        javaClassContent - original class content not null
        entity - not null
        Returns:
        the javadoc comment for the entity without any tags.
        Throws:
        java.io.IOException - if any
      • getJavadocComment

        java.lang.String getJavadocComment​(java.lang.String javaClassContent,
                                           com.thoughtworks.qdox.model.JavaAnnotatedElement entity,
                                           com.thoughtworks.qdox.model.DocletTag docletTag)
                                    throws java.io.IOException
        Work around for QDOX-146 about whitespace. Ideally we want to use docletTag.getValue()
        For instance, with the following snippet:

        1 
        2      /**
        3       * Dummy Javadoc comment.
        4       @param  s a String
        5       */
        6      public void  dummyMethod String s ){}


        The return will be:

        1       @param  s a String

        Parameters:
        javaClassContent - original class content not null
        entity - not null
        docletTag - not null
        Returns:
        the javadoc comment for the entity without Javadoc tags.
        Throws:
        java.io.IOException - if any
      • extractOriginalJavadoc

        static java.lang.String extractOriginalJavadoc​(java.lang.String javaClassContent,
                                                       com.thoughtworks.qdox.model.JavaAnnotatedElement entity)
                                                throws java.io.IOException
        Extract the original Javadoc and others comments up to START_JAVADOC form the entity. This method takes care of the Javadoc indentation. All javadoc lines will be trimmed on right.
        For instance, with the following snippet:

        1 
        2      /**
        3       * Dummy Javadoc comment.
        4       @param  s a String
        5       */
        6      public void  dummyMethod String s ){}


        The return will be:

        1      /**
        2       * Dummy Javadoc comment.
        3       @param  s a String
        4       */

        Parameters:
        javaClassContent - not null
        entity - not null
        Returns:
        return the original javadoc as String for the current entity
        Throws:
        java.io.IOException - if any
      • extractOriginalJavadocContent

        static java.lang.String extractOriginalJavadocContent​(java.lang.String javaClassContent,
                                                              com.thoughtworks.qdox.model.JavaAnnotatedElement entity)
                                                       throws java.io.IOException
        Extract the Javadoc comment between START_JAVADOC and END_JAVADOC form the entity. This method takes care of the Javadoc indentation. All javadoc lines will be trimmed on right.
        For instance, with the following snippet:

        1 
        2      /**
        3       * Dummy Javadoc comment.
        4       @param  s a String
        5       */
        6      public void  dummyMethod String s ){}


        The return will be:

        1       * Dummy Javadoc comment.
        2       @param  s a String

        Parameters:
        javaClassContent - not null
        entity - not null
        Returns:
        return the original javadoc as String for the current entity
        Throws:
        java.io.IOException - if any
      • removeLastEmptyJavadocLines

        private static java.lang.String removeLastEmptyJavadocLines​(java.lang.String content)
                                                             throws java.io.IOException
        Parameters:
        content - not null
        Returns:
        the content without last lines containing javadoc separator (ie * )
        Throws:
        java.io.IOException - if any
        See Also:
        getJavadocComment(String, JavaAnnotatedElement, DocletTag)
      • alignIndentationJavadocLines

        private static java.lang.String alignIndentationJavadocLines​(java.lang.String content,
                                                                     java.lang.String indent)
                                                              throws java.io.IOException
        Parameters:
        content - not null
        Returns:
        the javadoc comment with the given indentation
        Throws:
        java.io.IOException - if any
        See Also:
        getJavadocComment(String, JavaAnnotatedElement, DocletTag)
      • autodetectIndentation

        private static java.lang.String autodetectIndentation​(java.lang.String line)
        Autodetect the indentation of a given line:
         autodetectIndentation( null ) = "";
         autodetectIndentation( "a" ) = "";
         autodetectIndentation( "    a" ) = "    ";
         autodetectIndentation( "\ta" ) = "\t";
         
        Parameters:
        line - not null
        Returns:
        the indentation for the given line.
      • getLines

        private static java.lang.String[] getLines​(java.lang.String content)
                                            throws java.io.IOException
        Parameters:
        content - not null
        Returns:
        an array of all content lines
        Throws:
        java.io.IOException - if any
      • trimLeft

        private static java.lang.String trimLeft​(java.lang.String text)
        Trim a given line on the left:
         trimLeft( null ) = "";
         trimLeft( "  " ) = "";
         trimLeft( "a" ) = "a";
         trimLeft( "    a" ) = "a";
         trimLeft( "\ta" ) = "a";
         trimLeft( "    a    " ) = "a    ";
         
        Parameters:
        text -
        Returns:
        the text trimmed on left side or empty if text is null.
      • trimRight

        private static java.lang.String trimRight​(java.lang.String text)
        Trim a given line on the right:
         trimRight( null ) = "";
         trimRight( "  " ) = "";
         trimRight( "a" ) = "a";
         trimRight( "a\t" ) = "a";
         trimRight( "    a    " ) = "    a";
         
        Parameters:
        text -
        Returns:
        the text trimmed on tight side or empty if text is null.