001    package org.apache.maven.tools.plugin.javadoc;
002    
003    /*
004     * Licensed to the Apache Software Foundation (ASF) under one
005     * or more contributor license agreements.  See the NOTICE file
006     * distributed with this work for additional information
007     * regarding copyright ownership.  The ASF licenses this file
008     * to you under the Apache License, Version 2.0 (the
009     * "License"); you may not use this file except in compliance
010     * with the License.  You may obtain a copy of the License at
011     *
012     *   http://www.apache.org/licenses/LICENSE-2.0
013     *
014     * Unless required by applicable law or agreed to in writing,
015     * software distributed under the License is distributed on an
016     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017     * KIND, either express or implied.  See the License for the
018     * specific language governing permissions and limitations
019     * under the License.
020     */
021    
022    import java.util.Map;
023    
024    import org.apache.maven.tools.plugin.extractor.java.JavaMojoAnnotation;
025    
026    import com.sun.tools.doclets.Taglet;
027    
028    /**
029     * The <tt>@configurator</tt> tag is used to inject parameter values into the Mojo and has annotation parameter.
030     * <br/>
031     * The following is a sample declaration:
032     * <pre>
033     * &#x2f;&#x2a;&#x2a;
034     * &#x20;&#x2a; Dummy Mojo.
035     * &#x20;&#x2a;
036     * &#x20;&#x2a; &#64;configurator &lt;roleHint&gt;
037     * &#x20;&#x2a; ...
038     * &#x20;&#x2a;&#x2f;
039     * public class MyMojo extends AbstractMojo{}
040     * </pre>
041     * To use it, calling the <code>Javadoc</code> tool with the following:
042     * <pre>
043     * javadoc ... -taglet 'org.apache.maven.tools.plugin.javadoc.MojoConfiguratorTypeTaglet'
044     * </pre>
045     * <b>Note</b>: This taglet is similar to call the <code>Javadoc</code> tool with the following:
046     * <pre>
047     * javadoc ... -tag 'configurator:t:Is configured to the role hint:'
048     * </pre>
049     *
050     * @see <a href="package-summary.html#package_description">package-summary.html</a>
051     *
052     * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
053     * @version $Id: MojoConfiguratorTypeTaglet.java 1133707 2011-06-09 08:28:59Z stephenc $
054     */
055    public class MojoConfiguratorTypeTaglet
056        extends AbstractMojoTypeTaglet
057    {
058        /** The Javadoc annotation */
059        private static final String NAME = JavaMojoAnnotation.CONFIGURATOR;
060    
061        /** The Javadoc text which will be added to the generated page. */
062        protected static final String HEADER = "Is configured to the role hint";
063    
064        /**
065         * @return By default, return the string defined in {@linkplain #HEADER}.
066         * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getHeader()
067         * @see #HEADER
068         */
069        public String getHeader()
070        {
071            return HEADER;
072        }
073    
074        /**
075         * @return <code>"*"</code> since <code>@configurator</code> has a value.
076         * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getAllowedValue()
077         */
078        public String getAllowedValue()
079        {
080            return "*";
081        }
082    
083        /**
084         * @return <code>null</code> since <code>@configurator</code> has no parameter.
085         * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getAllowedParameterNames()
086         */
087        public String[] getAllowedParameterNames()
088        {
089            return null;
090        }
091    
092        /**
093         * @return By default, return the name of this taglet.
094         * @see com.sun.tools.doclets.Taglet#getName()
095         * @see MojoConfiguratorTypeTaglet#NAME
096         */
097        public String getName()
098        {
099            return NAME;
100        }
101    
102        /**
103         * Register this Taglet.
104         *
105         * @param tagletMap the map to register this tag to.
106         */
107        public static void register( Map<String, Taglet> tagletMap )
108        {
109            MojoConfiguratorTypeTaglet tag = new MojoConfiguratorTypeTaglet();
110            Taglet t = tagletMap.get( tag.getName() );
111            if ( t != null )
112            {
113                tagletMap.remove( tag.getName() );
114            }
115            tagletMap.put( tag.getName(), tag );
116        }
117    }