View Javadoc
1   package org.codehaus.plexus.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 com.sun.tools.doclets.Taglet;
25  
26  /**
27   * The <tt>@plexus.component</tt> tag is used to show that the class it annotates is a plexus component.
28   * This will add a <tt>&lt;component</tt>&gt; element to the <tt>&lt;components</tt>&gt; in components.xml.
29   * The following parameters are available, but remember the <tt>role</tt> is required.
30   * The text in the javadoc tag describing this class is copied into the component's <tt>&lt;description</tt>&gt; tag.
31   * <table class="bodyTable">
32   *   <tbody>
33   *     <tr class="a">
34   *       <td align="left"><b>Parameter</b></td>
35   *       <td align="left"><b>Required</b></td>
36   *       <td align="left"><b>Description</b></td>
37   *     </tr>
38   *     <tr class="b">
39   *       <td align="left">role</td>
40   *       <td align="left">Yes</td>
41   *       <td align="left">The role that this class provides an implementation for (usually the class name
42   *       of an implemented Interface</td>
43   *     </tr>
44   *     <tr class="a">
45   *       <td align="left">role-hint</td>
46   *       <td align="left">No</td>
47   *       <td align="left">The hints are used to differentiate multiple implementations of the same role</td>
48   *     </tr>
49   *       <tr class="b">
50   *       <td align="left">version</td>
51   *       <td align="left">No</td>
52   *       <td align="left">Set the version of the component</td>
53   *     </tr>
54   *   </tbody>
55   * </table>
56   *
57   * @see <a href="http://plexus.codehaus.org/guides/developer-guide/appendices/javadoc-tags-reference.html">
58   * http://plexus.codehaus.org/guides/developer-guide/appendices/javadoc-tags-reference.html</a>;
59   *
60   * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
61   * @version $Id$
62   */
63  public class PlexusComponentTaglet
64      extends AbstractPlexusTaglet
65  {
66      private static final String NAME = "plexus.component";
67  
68      private static final String HEADER = "Plexus component";
69  
70      /** {@inheritDoc} */
71      public String getHeader()
72      {
73          return HEADER;
74      }
75  
76      /** {@inheritDoc} */
77      public String getName()
78      {
79          return NAME;
80      }
81  
82      /** {@inheritDoc} */
83      public boolean inConstructor()
84      {
85          return false;
86      }
87  
88      /** {@inheritDoc} */
89      public boolean inField()
90      {
91          return false;
92      }
93  
94      /** {@inheritDoc} */
95      public boolean inMethod()
96      {
97          return false;
98      }
99  
100     /** {@inheritDoc} */
101     public boolean inOverview()
102     {
103         return false;
104     }
105 
106     /** {@inheritDoc} */
107     public boolean inPackage()
108     {
109         return false;
110     }
111 
112     /** {@inheritDoc} */
113     public boolean inType()
114     {
115         return true;
116     }
117 
118     /** {@inheritDoc} */
119     public boolean isInlineTag()
120     {
121         return false;
122     }
123 
124     /**
125      * Register this Taglet.
126      *
127      * @param tagletMap the map to register this tag to.
128      */
129     public static void register( Map tagletMap )
130     {
131         PlexusComponentTaglet tag = new PlexusComponentTaglet();
132         Taglet t = (Taglet) tagletMap.get( tag.getName() );
133         if ( t != null )
134         {
135             tagletMap.remove( tag.getName() );
136         }
137         tagletMap.put( tag.getName(), tag );
138     }
139 }