Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
MojoReadOnlyFieldTaglet |
|
| 1.2;1,2 |
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>@readonly</tt> tag is used to specify that this parameter cannot be configured directly by the | |
30 | * user and has no parameter. | |
31 | * <br/> | |
32 | * The following is a sample declaration: | |
33 | * <pre> | |
34 | * public class MyMojo extends AbstractMojo | |
35 | * { | |
36 | * /** | |
37 | *  * Dummy parameter. | |
38 | *  * | |
39 | *  * @readonly | |
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.MojoReadOnlyFieldTaglet' | |
48 | * </pre> | |
49 | * <b>Note</b>: This taglet is similar to call the <code>Javadoc</code> tool with the following: | |
50 | * <pre> | |
51 | * javadoc ... -tag 'readonly:f:Is readonly.' | |
52 | * </pre> | |
53 | * | |
54 | * @see <a href="package-summary.html#package_description">package-summary.html</a> | |
55 | * | |
56 | * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> | |
57 | * @version $Id: MojoReadOnlyFieldTaglet.java 1133707 2011-06-09 08:28:59Z stephenc $ | |
58 | */ | |
59 | 0 | public class MojoReadOnlyFieldTaglet |
60 | extends AbstractMojoFieldTaglet | |
61 | { | |
62 | /** The Javadoc annotation */ | |
63 | private static final String NAME = JavaMojoAnnotation.READONLY; | |
64 | ||
65 | /** The Javadoc text which will be added to the generated page. */ | |
66 | protected static final String HEADER = "Is readonly."; | |
67 | ||
68 | /** | |
69 | * @return By default, return the string defined in {@linkplain #HEADER}. | |
70 | * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getHeader() | |
71 | * @see #HEADER | |
72 | */ | |
73 | public String getHeader() | |
74 | { | |
75 | 0 | return HEADER; |
76 | } | |
77 | ||
78 | /** | |
79 | * @return <code>null</code> since <code>@readonly</code> has no value. | |
80 | * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getAllowedValue() | |
81 | */ | |
82 | public String getAllowedValue() | |
83 | { | |
84 | 0 | return null; |
85 | } | |
86 | ||
87 | /** | |
88 | * @return <code>null</code> since <code>@readonly</code> has no parameter. | |
89 | * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getAllowedParameterNames() | |
90 | */ | |
91 | public String[] getAllowedParameterNames() | |
92 | { | |
93 | 0 | return null; |
94 | } | |
95 | ||
96 | /** | |
97 | * @return By default, return the name of this taglet. | |
98 | * @see com.sun.tools.doclets.Taglet#getName() | |
99 | * @see MojoReadOnlyFieldTaglet#NAME | |
100 | */ | |
101 | public String getName() | |
102 | { | |
103 | 0 | return NAME; |
104 | } | |
105 | ||
106 | /** | |
107 | * Register this Taglet. | |
108 | * | |
109 | * @param tagletMap the map to register this tag to. | |
110 | */ | |
111 | public static void register( Map<String, Taglet> tagletMap ) | |
112 | { | |
113 | 0 | MojoReadOnlyFieldTaglet tag = new MojoReadOnlyFieldTaglet(); |
114 | 0 | Taglet t = tagletMap.get( tag.getName() ); |
115 | 0 | if ( t != null ) |
116 | { | |
117 | 0 | tagletMap.remove( tag.getName() ); |
118 | } | |
119 | 0 | tagletMap.put( tag.getName(), tag ); |
120 | 0 | } |
121 | } |