EMMA Coverage Report (generated Thu Nov 26 15:54:18 CST 2009)
[all classes][org.eclipse.pde.api.tools.internal]

COVERAGE SUMMARY FOR SOURCE FILE [JavadocTagManager.java]

nameclass, %method, %block, %line, %
JavadocTagManager.java100% (1/1)100% (7/7)98%  (301/306)98%  (93/95)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class JavadocTagManager100% (1/1)100% (7/7)98%  (301/306)98%  (93/95)
getAllTags (): IApiJavadocTag [] 100% (1/1)84%  (16/19)80%  (4/5)
getRestrictionsForTag (String, int, int): int 100% (1/1)95%  (36/38)89%  (8/9)
JavadocTagManager (): void 100% (1/1)100% (6/6)100% (2/2)
getAllTagNames (): Set 100% (1/1)100% (26/26)100% (5/5)
getTag (String): IApiJavadocTag 100% (1/1)100% (8/8)100% (2/2)
getTagsForType (int, int): IApiJavadocTag [] 100% (1/1)100% (37/37)100% (6/6)
initializeJavadocTags (): void 100% (1/1)100% (172/172)100% (66/66)

1/*******************************************************************************
2 * Copyright (c) 2007, 2008 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 *     IBM Corporation - initial API and implementation
10 *******************************************************************************/
11package org.eclipse.pde.api.tools.internal;
12 
13import java.util.ArrayList;
14import java.util.Collection;
15import java.util.HashMap;
16import java.util.HashSet;
17import java.util.List;
18import java.util.Set;
19 
20import org.eclipse.pde.api.tools.internal.provisional.IApiJavadocTag;
21import org.eclipse.pde.api.tools.internal.provisional.RestrictionModifiers;
22 
23/**
24 * Manages contributed javadoc tags. This manager is lazy, in that
25 * nothing is loaded until it is asked for.
26 * 
27 * @since 1.0.0
28 */
29public final class JavadocTagManager {
30 
31        /**
32         * Cache for the contributed javadoc tags. 
33         * Cache form:
34         * <pre>
35         * HashMap<String(id), tag>
36         * </pre>
37         */
38        private HashMap tagcache = null;
39        
40        /**
41         * Collection of tag extensions
42         */
43        private IApiJavadocTag[] tags;
44        
45        /**
46         * Initializes the cache of contributed Javadoc tags.
47         * If the cache has already been initialized no work is done.
48         */
49        private void initializeJavadocTags() {
50                if(tagcache == null) {
51                        tagcache = new HashMap();
52                        List list = new ArrayList(4);
53                        
54                        //noimplement tag
55                        ApiJavadocTag newtag = new ApiJavadocTag(IApiJavadocTag.NO_IMPLEMENT_TAG_ID, 
56                                        "noimplement", //$NON-NLS-1$
57                                        RestrictionModifiers.NO_IMPLEMENT);
58                        newtag.setApplicableTo(IApiJavadocTag.TYPE_INTERFACE, 
59                                        IApiJavadocTag.MEMBER_NONE, 
60                                        "This interface is not intended to be implemented by clients.");   //$NON-NLS-1$
61                        tagcache.put(newtag.getTagId(), newtag);
62                        list.add(newtag);
63                        
64                        //noextend tag
65                        newtag = new ApiJavadocTag(IApiJavadocTag.NO_EXTEND_TAG_ID, 
66                                        "noextend", //$NON-NLS-1$
67                                        RestrictionModifiers.NO_EXTEND);
68                        newtag.setApplicableTo(IApiJavadocTag.TYPE_CLASS, 
69                                        IApiJavadocTag.MEMBER_NONE, 
70                                        "This class is not intended to be subclassed by clients.");  //$NON-NLS-1$
71                        newtag.setApplicableTo(IApiJavadocTag.TYPE_INTERFACE, 
72                                        IApiJavadocTag.MEMBER_NONE, 
73                                        "This interface is not intended to be extended by clients.");  //$NON-NLS-1$
74                        tagcache.put(newtag.getTagId(), newtag);
75                        list.add(newtag);
76                        
77                        //nooverride tag
78                        newtag = new ApiJavadocTag(IApiJavadocTag.NO_OVERRIDE_TAG_ID,
79                                        "nooverride", //$NON-NLS-1$
80                                        RestrictionModifiers.NO_OVERRIDE);
81                        newtag.setApplicableTo(IApiJavadocTag.TYPE_CLASS, 
82                                         IApiJavadocTag.MEMBER_METHOD, 
83                                         "This method is not intended to be re-implemented or extended by clients.");  //$NON-NLS-1$
84                        tagcache.put(newtag.getTagId(), newtag);
85                        list.add(newtag);
86                        
87                        //noinstantiate tag
88                        newtag = new ApiJavadocTag(IApiJavadocTag.NO_INSTANTIATE_TAG_ID,
89                                        "noinstantiate", //$NON-NLS-1$
90                                        RestrictionModifiers.NO_INSTANTIATE);
91                        newtag.setApplicableTo(IApiJavadocTag.TYPE_CLASS,
92                                        IApiJavadocTag.MEMBER_NONE, 
93                                        "This class is not intended to be instantiated by clients.");  //$NON-NLS-1$
94                        tagcache.put(newtag.getTagId(), newtag);
95                        list.add(newtag);
96                        
97                        //noreference tag
98                        newtag = new ApiJavadocTag(IApiJavadocTag.NO_REFERENCE_TAG_ID,
99                                        "noreference", //$NON-NLS-1$
100                                        RestrictionModifiers.NO_REFERENCE);
101                        newtag.setApplicableTo(IApiJavadocTag.TYPE_CLASS, 
102                                        IApiJavadocTag.MEMBER_METHOD, 
103                                        "This method is not intended to be referenced by clients."); //$NON-NLS-1$
104                        newtag.setApplicableTo(IApiJavadocTag.TYPE_INTERFACE, 
105                                        IApiJavadocTag.MEMBER_METHOD, 
106                                        "This method is not intended to be referenced by clients."); //$NON-NLS-1$
107                        newtag.setApplicableTo(IApiJavadocTag.TYPE_CLASS, 
108                                        IApiJavadocTag.MEMBER_FIELD, 
109                                        "This field is not intended to be referenced by clients."); //$NON-NLS-1$
110                        newtag.setApplicableTo(IApiJavadocTag.TYPE_INTERFACE, 
111                                        IApiJavadocTag.MEMBER_FIELD, 
112                                        "This field is not intended to be referenced by clients."); //$NON-NLS-1$
113                        newtag.setApplicableTo(IApiJavadocTag.TYPE_CLASS, 
114                                        IApiJavadocTag.MEMBER_CONSTRUCTOR, 
115                                        "This constructor is not intended to be referenced by clients."); //$NON-NLS-1$
116                        newtag.setApplicableTo(IApiJavadocTag.TYPE_ENUM, 
117                                        IApiJavadocTag.MEMBER_FIELD, 
118                                        "This enum field is not intended to be referenced by clients."); //$NON-NLS-1$
119                        newtag.setApplicableTo(IApiJavadocTag.TYPE_ENUM, 
120                                        IApiJavadocTag.MEMBER_METHOD, 
121                                        "This enum method is not intended to be referenced by clients."); //$NON-NLS-1$
122                        tagcache.put(newtag.getTagId(), newtag);
123                        list.add(newtag);
124                        tags = (IApiJavadocTag[]) list.toArray(new IApiJavadocTag[list.size()]);
125                }
126        }
127        
128        /**
129         * Returns all of the java doc tags for a given kind of type and member. See
130         * {@link IApiJavadocTag} for a complete listing of tag Java type and member types.
131         * 
132         * @param type one of <code>CLASS</code> or <code>INTERFACE</code>
133         * @param member one of <code>METHOD</code> or <code>FIELD</code> or <code>NONE</code> 
134         * @return an array of {@link IApiJavadocTag}s that apply to the specified 
135         * Java type or an empty array, never <code>null</code>
136         */
137        public synchronized IApiJavadocTag[] getTagsForType(int type, int member) {
138                initializeJavadocTags();
139                List list = new ArrayList();
140                for (int i = 0; i < tags.length; i++) {
141                        if (tags[i].isApplicable(type, member)) {
142                                list.add(tags[i]);
143                        }
144                }
145                return (IApiJavadocTag[]) list.toArray(new IApiJavadocTag[list.size()]);
146        }
147        
148        /**
149         * Returns the {@link IApiJavadocTag} that has the given id or <code>null</code> if there is 
150         * no tag with the given id
151         * @param id the id of the tag to fetch
152         * @return the {@link IApiJavadocTag} with the given id or <code>null</code>
153         */
154        public synchronized IApiJavadocTag getTag(String id) {
155                initializeJavadocTags();
156                return (IApiJavadocTag) tagcache.get(id);
157        }
158        
159        /**
160         * Returns the complete listing of {@link IApiJavadocTag}s contained in the manager or an empty 
161         * array, never <code>null</code>
162         * @return the complete listing of tags in the manager or <code>null</code>
163         */
164        public synchronized IApiJavadocTag[] getAllTags() {
165                initializeJavadocTags();
166                if(tagcache == null) {
167                        return new IApiJavadocTag[0];
168                }
169                Collection values = tagcache.values();
170                return (IApiJavadocTag[]) values.toArray(new IApiJavadocTag[values.size()]);
171        }
172        
173        /**
174         * @return The complete set of tags names that this manager currently knows about.
175         */
176        public synchronized Set getAllTagNames() {
177                IApiJavadocTag[] tags = getAllTags();
178                HashSet names = new HashSet(tags.length);
179                for(int i = 0; i < tags.length; i++) {
180                        names.add(tags[i].getTagName());
181                }
182                return names;
183        }
184        
185        /**
186         * Returns the restriction modifier set on the javadoc tag with the given name.
187         * If the manager has no entry for the specified tag name <code>-1</code> is returned.
188         * 
189         * @param tagname the name of the tag
190         * @param type one of <code>CLASS</code> or <code>INTERFACE</code>
191         * @param member one of <code>METHOD</code> or <code>FIELD</code> or <code>NONE</code> 
192         * @return the restriction modifier for the given tag name or {@link RestrictionModifiers#NO_RESTRICTIONS} if not found
193         */
194        public synchronized int getRestrictionsForTag(String tagname, int type, int member) {
195                if(tagname == null) {
196                        return RestrictionModifiers.NO_RESTRICTIONS;
197                }
198                initializeJavadocTags();
199                ApiJavadocTag tag = null;
200                for (int i = 0; i < tags.length; i++) {
201                        tag = (ApiJavadocTag) tags[i];
202                        if (tag.getTagName().equals(tagname) && (tag.isApplicable(type, member))) {
203                                return tag.getRestrictionModifier();
204                        }
205                }
206                return RestrictionModifiers.NO_RESTRICTIONS;
207        }
208}

[all classes][org.eclipse.pde.api.tools.internal]
EMMA 2.0.5312 EclEmma Fix 1 (C) Vladimir Roubtsov