Class GeneratorUtils


  • public final class GeneratorUtils
    extends java.lang.Object
    Convenience methods to play with Maven plugins.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private GeneratorUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static java.lang.String decodeJavadocTags​(java.lang.String description)
      Decodes javadoc inline tags into equivalent HTML tags.
      static java.lang.String discoverPackageName​(org.apache.maven.plugin.descriptor.PluginDescriptor pluginDescriptor)
      Find the best package name, based on the number of hits of actual Mojo classes.
      static void element​(org.codehaus.plexus.util.xml.XMLWriter w, java.lang.String name, java.lang.String value)  
      static void element​(org.codehaus.plexus.util.xml.XMLWriter w, java.lang.String name, java.lang.String value, boolean asText)  
      static boolean isMavenReport​(java.lang.String impl, org.apache.maven.project.MavenProject project)  
      static java.lang.String makeHtmlValid​(java.lang.String description)
      Fixes some javadoc comment to become a valid XHTML snippet.
      private static java.lang.String quoteReplacement​(java.lang.String s)
      Returns a literal replacement String for the specified String.
      static java.util.List<org.codehaus.plexus.component.repository.ComponentDependency> toComponentDependencies​(java.util.List<org.apache.maven.model.Dependency> dependencies)  
      static java.lang.String toText​(java.lang.String html)
      Converts a HTML fragment as extracted from a javadoc comment to a plain text string.
      static void writeDependencies​(org.codehaus.plexus.util.xml.XMLWriter w, org.apache.maven.plugin.descriptor.PluginDescriptor pluginDescriptor)  
      • Methods inherited from class java.lang.Object

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

      • GeneratorUtils

        private GeneratorUtils()
    • Method Detail

      • writeDependencies

        public static void writeDependencies​(org.codehaus.plexus.util.xml.XMLWriter w,
                                             org.apache.maven.plugin.descriptor.PluginDescriptor pluginDescriptor)
        Parameters:
        w - not null writer
        pluginDescriptor - not null
      • element

        public static void element​(org.codehaus.plexus.util.xml.XMLWriter w,
                                   java.lang.String name,
                                   java.lang.String value)
        Parameters:
        w - not null writer
        name - not null
        value - could be null
      • element

        public static void element​(org.codehaus.plexus.util.xml.XMLWriter w,
                                   java.lang.String name,
                                   java.lang.String value,
                                   boolean asText)
      • toComponentDependencies

        public static java.util.List<org.codehaus.plexus.component.repository.ComponentDependency> toComponentDependencies​(java.util.List<org.apache.maven.model.Dependency> dependencies)
        Parameters:
        dependencies - not null list of Dependency
        Returns:
        list of component dependencies
      • quoteReplacement

        private static java.lang.String quoteReplacement​(java.lang.String s)
        Returns a literal replacement String for the specified String. This method produces a String that will work as a literal replacement s in the appendReplacement method of the Matcher class. The String produced will match the sequence of characters in s treated as a literal sequence. Slashes ('\') and dollar signs ('$') will be given no special meaning. TODO: copied from Matcher class of Java 1.5, remove once target platform can be upgraded
        Parameters:
        s - The string to be literalized
        Returns:
        A literal string replacement
        See Also:
        java.util.regex.Matcher
      • decodeJavadocTags

        static java.lang.String decodeJavadocTags​(java.lang.String description)
        Decodes javadoc inline tags into equivalent HTML tags. For instance, the inline tag "<A&B>" should be rendered as "<A&B>".
        Parameters:
        description - The javadoc description to decode, may be null.
        Returns:
        The decoded description, never null.
      • makeHtmlValid

        public static java.lang.String makeHtmlValid​(java.lang.String description)
        Fixes some javadoc comment to become a valid XHTML snippet.
        Parameters:
        description - Javadoc description with HTML tags, may be null.
        Returns:
        The description with valid XHTML tags, never null.
      • toText

        public static java.lang.String toText​(java.lang.String html)
        Converts a HTML fragment as extracted from a javadoc comment to a plain text string. This method tries to retain as much of the text formatting as possible by means of the following transformations:
        • List items are converted to leading tabs (U+0009), followed by the item number/bullet, another tab and finally the item contents. Each tab denotes an increase of indentation.
        • Flow breaking elements as well as literal line terminators in preformatted text are converted to a newline (U+000A) to denote a mandatory line break.
        • Consecutive spaces and line terminators from character data outside of preformatted text will be normalized to a single space. The resulting space denotes a possible point for line wrapping.
        • Each space in preformatted text will be converted to a non-breaking space (U+00A0).
        Parameters:
        html - The HTML fragment to convert to plain text, may be null.
        Returns:
        A string with HTML tags converted into pure text, never null.
        Since:
        2.4.3
      • discoverPackageName

        public static java.lang.String discoverPackageName​(org.apache.maven.plugin.descriptor.PluginDescriptor pluginDescriptor)
        Find the best package name, based on the number of hits of actual Mojo classes.
        Parameters:
        pluginDescriptor - not null
        Returns:
        the best name of the package for the generated mojo
      • isMavenReport

        public static boolean isMavenReport​(java.lang.String impl,
                                            org.apache.maven.project.MavenProject project)
                                     throws java.lang.IllegalArgumentException
        Parameters:
        impl - a Mojo implementation, not null
        project - a MavenProject instance, could be null
        Returns:
        true is the Mojo implementation implements MavenReport, false otherwise.
        Throws:
        java.lang.IllegalArgumentException - if any