001package 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
022import java.util.Map;
023
024import org.apache.maven.tools.plugin.extractor.java.JavaMojoAnnotation;
025
026import com.sun.tools.doclets.Taglet;
027
028/**
029 * The <tt>@parameter</tt> tag is used to define a Mojo parameter and has annotation parameter.
030 * <br/>
031 * The following is a sample declaration:
032 * <pre>
033 * public class MyMojo extends AbstractMojo
034 * {
035 *   &#x2f;&#x2a;&#x2a;
036 *   &#x20;&#x2a; Dummy parameter.
037 *   &#x20;&#x2a;
038 *   &#x20;&#x2a; &#64;parameter &lt;name="..."&gt; &lt;alias="..."&gt; &lt;default-value="..."&gt; &lt;expression="..."&gt;
039 *   &#x20;&#x2a; &lt;implementation="..."&gt; &lt;property="..."&gt;
040 *   &#x20;&#x2a; ...
041 *   &#x20;&#x2a;&#x2f;
042 *   private Object parameterName;
043 * }
044 * </pre>
045 * To use it, calling the <code>Javadoc</code> tool with the following:
046 * <pre>
047 * javadoc ... -taglet 'org.apache.maven.tools.plugin.javadoc.MojoParameterFieldTaglet'
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: MojoParameterFieldTaglet.html 907947 2014-05-03 19:43:49Z hboutemy $
054 */
055public class MojoParameterFieldTaglet
056    extends AbstractMojoFieldTaglet
057{
058    /** The Javadoc annotation */
059    private static final String NAME = JavaMojoAnnotation.PARAMETER;
060
061    private static final String[] PARAMETERS_NAME = {
062        JavaMojoAnnotation.PARAMETER_NAME,
063        JavaMojoAnnotation.PARAMETER_ALIAS,
064        JavaMojoAnnotation.PARAMETER_DEFAULT_VALUE,
065        JavaMojoAnnotation.PARAMETER_EXPRESSION,
066        JavaMojoAnnotation.PARAMETER_IMPLEMENTATION,
067        JavaMojoAnnotation.PARAMETER_PROPERTY };
068
069    /** The Javadoc text which will be added to the generated page. */
070    protected static final String HEADER = "Is defined by";
071
072    /**
073     * @return By default, return the string defined in {@linkplain #HEADER}.
074     * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getHeader()
075     * @see #HEADER
076     */
077    public String getHeader()
078    {
079        return HEADER;
080    }
081
082    /**
083     * @return <code>null</code> since <code>@parameter</code> has no value.
084     * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getAllowedValue()
085     */
086    public String getAllowedValue()
087    {
088        return null;
089    }
090
091    /**
092     * @return <code>MojoParameterFieldTaglet#PARAMETERS_NAME</code> since <code>@parameter</code> has parameters.
093     * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getAllowedParameterNames()
094     */
095    public String[] getAllowedParameterNames()
096    {
097        return PARAMETERS_NAME;
098    }
099
100    /**
101     * @return By default, return the name of this taglet.
102     * @see com.sun.tools.doclets.Taglet#getName()
103     * @see MojoParameterFieldTaglet#NAME
104     */
105    public String getName()
106    {
107        return NAME;
108    }
109
110    /**
111     * Register this Taglet.
112     *
113     * @param tagletMap the map to register this tag to.
114     */
115    public static void register( Map<String, Taglet> tagletMap )
116    {
117        MojoParameterFieldTaglet tag = new MojoParameterFieldTaglet();
118        Taglet t = tagletMap.get( tag.getName() );
119        if ( t != null )
120        {
121            tagletMap.remove( tag.getName() );
122        }
123        tagletMap.put( tag.getName(), tag );
124    }
125}