1 package org.apache.maven.tools.plugin.javadoc;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import java.util.Map;
23
24 import org.apache.maven.tools.plugin.extractor.java.JavaMojoAnnotation;
25
26 import com.sun.tools.doclets.Taglet;
27
28 /**
29 * The <tt>@parameter</tt> tag is used to define a Mojo parameter and has annotation parameter.
30 * <br/>
31 * The following is a sample declaration:
32 * <pre>
33 * public class MyMojo extends AbstractMojo
34 * {
35 * /**
36 *  * Dummy parameter.
37 *  *
38 *  * @parameter <name="..."> <alias="..."> <default-value="..."> <expression="...">
39 *  * <implementation="..."> <property="...">
40 *  * ...
41 *  */
42 * private Object parameterName;
43 * }
44 * </pre>
45 * To use it, calling the <code>Javadoc</code> tool with the following:
46 * <pre>
47 * javadoc ... -taglet 'org.apache.maven.tools.plugin.javadoc.MojoParameterFieldTaglet'
48 * </pre>
49 *
50 * @see <a href="package-summary.html#package_description">package-summary.html</a>
51 *
52 * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
53 * @version $Id: MojoParameterFieldTaglet.html 907947 2014-05-03 19:43:49Z hboutemy $
54 */
55 public class MojoParameterFieldTaglet
56 extends AbstractMojoFieldTaglet
57 {
58 /** The Javadoc annotation */
59 private static final String NAME = JavaMojoAnnotation.PARAMETER;
60
61 private static final String[] PARAMETERS_NAME = {
62 JavaMojoAnnotation.PARAMETER_NAME,
63 JavaMojoAnnotation.PARAMETER_ALIAS,
64 JavaMojoAnnotation.PARAMETER_DEFAULT_VALUE,
65 JavaMojoAnnotation.PARAMETER_EXPRESSION,
66 JavaMojoAnnotation.PARAMETER_IMPLEMENTATION,
67 JavaMojoAnnotation.PARAMETER_PROPERTY };
68
69 /** The Javadoc text which will be added to the generated page. */
70 protected static final String HEADER = "Is defined by";
71
72 /**
73 * @return By default, return the string defined in {@linkplain #HEADER}.
74 * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getHeader()
75 * @see #HEADER
76 */
77 public String getHeader()
78 {
79 return HEADER;
80 }
81
82 /**
83 * @return <code>null</code> since <code>@parameter</code> has no value.
84 * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getAllowedValue()
85 */
86 public String getAllowedValue()
87 {
88 return null;
89 }
90
91 /**
92 * @return <code>MojoParameterFieldTaglet#PARAMETERS_NAME</code> since <code>@parameter</code> has parameters.
93 * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getAllowedParameterNames()
94 */
95 public String[] getAllowedParameterNames()
96 {
97 return PARAMETERS_NAME;
98 }
99
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 }