View Javadoc
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>@requiresDirectInvocation</tt> tag is used to allow this Mojo to be direct invoked by the user.
30   * and has parameter.
31   * <br/>
32   * The following is a sample declaration:
33   * <pre>
34   * &#x2f;&#x2a;&#x2a;
35   * &#x20;&#x2a; Dummy Mojo.
36   * &#x20;&#x2a;
37   * &#x20;&#x2a; &#64;requiresDirectInvocation &lt;true|false&gt;
38   * &#x20;&#x2a; ...
39   * &#x20;&#x2a;&#x2f;
40   * public class MyMojo extends AbstractMojo{}
41   * </pre>
42   * To use it, calling the <code>Javadoc</code> tool with the following:
43   * <pre>
44   * javadoc ... -taglet 'org.apache.maven.tools.plugin.javadoc.MojoRequiresDirectInvocationTypeTaglet'
45   * </pre>
46   * <b>Note</b>: This taglet is similar to call the <code>Javadoc</code> tool with the following:
47   * <pre>
48   * javadoc ... -tag 'requiresDirectInvocation:t:Requires a direct invocation by the user'
49   * </pre>
50   *
51   * @see <a href="package-summary.html#package_description">package-summary.html</a>
52   *
53   * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
54   * @version $Id: MojoRequiresDirectInvocationTypeTaglet.html 907040 2014-04-27 09:50:12Z hboutemy $
55   */
56  public class MojoRequiresDirectInvocationTypeTaglet
57      extends AbstractMojoTypeTaglet
58  {
59      /** The Javadoc annotation */
60      private static final String NAME = JavaMojoAnnotation.REQUIRES_DIRECT_INVOCATION;
61  
62      /** The Javadoc text which will be added to the generated page. */
63      protected static final String HEADER = "Requires a direct invocation by the user";
64  
65      /**
66       * @return By default, return the string defined in {@linkplain #HEADER}.
67       * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getHeader()
68       * @see #HEADER
69       */
70      public String getHeader()
71      {
72          return HEADER;
73      }
74  
75      /**
76       * @return <code>"false|true"</code> since <code>@requiresDirectInvocation</code> has value.
77       * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getAllowedValue()
78       */
79      public String getAllowedValue()
80      {
81          return "false|true";
82      }
83  
84      /**
85       * @return <code>null</code> since <code>@requiresDirectInvocation</code> has no parameter.
86       * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getAllowedParameterNames()
87       */
88      public String[] getAllowedParameterNames()
89      {
90          return null;
91      }
92  
93      /**
94       * @return By default, return the name of this taglet.
95       * @see com.sun.tools.doclets.Taglet#getName()
96       * @see MojoRequiresDirectInvocationTypeTaglet#NAME
97       */
98      public String getName()
99      {
100         return NAME;
101     }
102 
103     /**
104      * Register this Taglet.
105      *
106      * @param tagletMap the map to register this tag to.
107      */
108     public static void register( Map<String, Taglet> tagletMap )
109     {
110         MojoRequiresDirectInvocationTypeTaglet tag = new MojoRequiresDirectInvocationTypeTaglet();
111         Taglet t = tagletMap.get( tag.getName() );
112         if ( t != null )
113         {
114             tagletMap.remove( tag.getName() );
115         }
116         tagletMap.put( tag.getName(), tag );
117     }
118 }