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 java.util.Map;
023
024 import org.apache.maven.tools.plugin.extractor.java.JavaMojoAnnotation;
025
026 import com.sun.tools.doclets.Taglet;
027
028 /**
029 * The <tt>@instantiationStrategy</tt> tag is used to specify the instantiation strategy and has has parameter.
030 * <br/>
031 * The following is a sample declaration:
032 * <pre>
033 * /**
034 *  * Dummy Mojo.
035 *  *
036 *  * @instantiationStrategy <per-lookup>
037 *  * ...
038 *  */
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.MojoInstantiationStrategyTypeTaglet'
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 'instantiationStrategy:t:Is instantiated with the strategy:'
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: MojoInstantiationStrategyTypeTaglet.java 1133707 2011-06-09 08:28:59Z stephenc $
054 */
055 public class MojoInstantiationStrategyTypeTaglet
056 extends AbstractMojoTypeTaglet
057 {
058 /** The Javadoc annotation */
059 private static final String NAME = JavaMojoAnnotation.INSTANTIATION_STRATEGY;
060
061 /** The Javadoc text which will be added to the generated page. */
062 protected static final String HEADER = "Is instantiated with the strategy";
063
064 /**
065 * @return By default, return the string defined in {@linkplain #HEADER}.
066 * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getHeader()
067 * @see #HEADER
068 */
069 public String getHeader()
070 {
071 return HEADER;
072 }
073
074 /**
075 * @return <code>"*"</code> since <code>@instantiationStrategy</code> has value.
076 * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getAllowedValue()
077 */
078 public String getAllowedValue()
079 {
080 return "*";
081 }
082
083 /**
084 * @return <code>null</code> since <code>@instantiationStrategy</code> has no parameter.
085 * @see org.apache.maven.tools.plugin.javadoc.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 MojoInstantiationStrategyTypeTaglet#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 MojoInstantiationStrategyTypeTaglet tag = new MojoInstantiationStrategyTypeTaglet();
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 }