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 com.sun.tools.doclets.Taglet;
023    import org.apache.maven.tools.plugin.extractor.java.JavaMojoAnnotation;
024    
025    import java.util.Map;
026    
027    /**
028     * The <tt>@requiresDependencyCollection</tt> tag is used to specify the required dependencies in the specified scope
029     * and has 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;requiresDependencyCollection &lt;requiredScope&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.MojoRequiresDependencyCollectionTypeTaglet'
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 'requiresDependencyCollection:t:Requires the collection of the dependencies in this specified scope:'
048     * </pre>
049     *
050     * @see <a href="package-summary.html#package_description">package-summary.html</a>
051     *
052     * @author Kristian Rosenvold
053     * @version $Id$
054     */
055    public class MojoRequiresDependencyCollectionTypeTaglet
056        extends AbstractMojoTypeTaglet
057    {
058        /** The Javadoc annotation */
059        private static final String NAME = JavaMojoAnnotation.REQUIRES_DEPENDENCY_COLLECTION;
060    
061        /** The Javadoc text which will be added to the generated page. */
062        protected static final String HEADER = "Collects the dependencies in this specified scope";
063    
064        /**
065         * @return By default, return the string defined in {@linkplain #HEADER}.
066         * @see AbstractMojoTaglet#getHeader()
067         * @see #HEADER
068         */
069        public String getHeader()
070        {
071            return HEADER;
072        }
073    
074        /**
075         * @return <code>"*"</code> since <code>@requiresDependencyCollection</code> has value.
076         * @see AbstractMojoTaglet#getAllowedValue()
077         */
078        public String getAllowedValue()
079        {
080            return "*";
081        }
082    
083        /**
084         * @return <code>null</code> since <code>@requiresDependencyCollection</code> has no parameter.
085         * @see 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 org.apache.maven.tools.plugin.javadoc.MojoRequiresDependencyCollectionTypeTaglet#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            MojoRequiresDependencyCollectionTypeTaglet tag = new MojoRequiresDependencyCollectionTypeTaglet();
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    }