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 [ApiJavadocTag.java]

nameclass, %method, %block, %line, %
ApiJavadocTag.java100% (1/1)92%  (12/13)90%  (169/188)89%  (41.9/47)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ApiJavadocTag100% (1/1)92%  (12/13)90%  (169/188)89%  (41.9/47)
toString (): String 0%   (0/1)0%   (0/3)0%   (0/1)
equals (Object): boolean 100% (1/1)57%  (12/21)60%  (3/5)
getTagComment (int, int): String 100% (1/1)80%  (16/20)72%  (2.9/4)
getCompleteTag (int, int): String 100% (1/1)91%  (29/32)88%  (7/8)
<static initializer> 100% (1/1)100% (3/3)100% (2/2)
ApiJavadocTag (String, String, int): void 100% (1/1)100% (31/31)100% (12/12)
getRestrictionModifier (): int 100% (1/1)100% (3/3)100% (1/1)
getTagId (): String 100% (1/1)100% (3/3)100% (1/1)
getTagKey (int, int): Integer 100% (1/1)100% (10/10)100% (1/1)
getTagName (): String 100% (1/1)100% (23/23)100% (6/6)
hashCode (): int 100% (1/1)100% (4/4)100% (1/1)
isApplicable (int, int): boolean 100% (1/1)100% (16/16)100% (1/1)
setApplicableTo (int, int, String): void 100% (1/1)100% (19/19)100% (4/4)

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.HashMap;
14 
15import org.eclipse.core.runtime.Assert;
16import org.eclipse.pde.api.tools.internal.provisional.IApiJavadocTag;
17import org.eclipse.pde.api.tools.internal.provisional.RestrictionModifiers;
18 
19/**
20 * Base API tools Javadoc tag implementation
21 * 
22 * @since 1.0.0
23 * @noextend This class is not intended to be subclassed by clients.
24 * @noinstantiate This class is not intended to be instantiated by clients.
25 */
26public class ApiJavadocTag implements IApiJavadocTag {
27 
28        /**
29         * The id of the tag
30         */
31        private String fId = null;
32        /**
33         * The name of the tag (immediately proceeding the '@' symbol
34         */
35        private String fName = null;
36        /**
37         * Map of integer ids to comments
38         */
39        private HashMap fTagItems = null;
40        
41        private static String EMPTY_STRING = ""; //$NON-NLS-1$
42        /**
43         * restriction modifier for the tag
44         */
45        private int fRModifier = RestrictionModifiers.NO_RESTRICTIONS;
46 
47        /**
48         * Lazily computed tag label, cached once it has been computed
49         */
50        private String fTaglabel = null;
51        
52        /**
53         * Constructor
54         * @param id the id of the tag
55         * @param name the name of the tag (not including the '@' symbol)
56         * @param rmodifier 
57         */
58        public ApiJavadocTag(String id, String name, int rmodifier) {
59                Assert.isNotNull(id);
60                fId = id;
61                Assert.isNotNull(name);
62                fName = name;
63                fRModifier = rmodifier;
64        }
65        
66        /* (non-Javadoc)
67         * @see org.eclipse.pde.api.tools.model.IApiJavadocTag#getTagId()
68         */
69        public String getTagId() {
70                return fId;
71        }
72        
73        /* (non-Javadoc)
74         * @see org.eclipse.pde.api.tools.model.IApiJavadocTag#getRestrictionModifier()
75         */
76        public int getRestrictionModifier() {
77                return fRModifier;
78        }
79 
80        /* (non-Javadoc)
81         * @see org.eclipse.pde.api.tools.internal.provisional.IApiJavadocTag#setApplicableTo(int, int, java.lang.String)
82         */
83        public void setApplicableTo(int type, int member, String comment) {
84                if(fTagItems == null) {
85                        fTagItems = new HashMap(6);
86                }
87                fTagItems.put(getTagKey(type, member), comment);
88        }
89        
90        /**
91         * Returns the comment for the given type ad member
92         * @param type
93         * @param member
94         * @return the comment for the tag
95         */
96        public String getTagComment(int type, int member) {
97                if(fTagItems == null) {
98                        return EMPTY_STRING;
99                }
100                Object obj = fTagItems.get(getTagKey(type, member));
101                return (String) (obj == null ? EMPTY_STRING : obj);
102        }
103        
104        /* (non-Javadoc)
105         * @see org.eclipse.pde.api.tools.model.IApiJavadocTag#getTagLabel()
106         */
107        public String getTagName() {
108                if(fTaglabel == null) {
109                        StringBuffer tag = new StringBuffer();
110                        tag.append("@"); //$NON-NLS-1$
111                        tag.append(fName);
112                        fTaglabel = tag.toString();
113                }
114                return fTaglabel;
115        }
116        
117        /* (non-Javadoc)
118         * @see java.lang.Object#toString()
119         */
120        public String toString() {
121                return getTagName();
122        }
123 
124        /* (non-Javadoc)
125         * @see org.eclipse.pde.api.tools.IApiJavadocTag#getCompleteTag(int, int)
126         */
127        public String getCompleteTag(int type, int member) {
128                StringBuffer tag = new StringBuffer();
129                tag.append(getTagName());
130                String comment = getTagComment(type, member);
131                if(EMPTY_STRING.equals(comment)) {
132                        return tag.toString();
133                }
134                tag.append(" "); //$NON-NLS-1$
135                tag.append(comment);
136                return tag.toString();
137        }
138 
139        /* (non-Javadoc)
140         * @see org.eclipse.pde.api.tools.IApiJavadocTag#isApplicable(int, int)
141         */
142        public boolean isApplicable(int type, int member) {
143                return fTagItems != null && fTagItems.keySet().contains(getTagKey(type, member));
144        }
145        
146        /* (non-Javadoc)
147         * @see java.lang.Object#equals(java.lang.Object)
148         */
149        public boolean equals(Object obj) {
150                if(obj instanceof IApiJavadocTag) {
151                        return ((IApiJavadocTag)obj).getTagName().equals(getTagName());
152                }
153                if(obj instanceof String) {
154                        return ((String)obj).equals(getTagName());
155                }
156                return false;
157        }
158        
159        /* (non-Javadoc)
160         * @see java.lang.Object#hashCode()
161         */
162        public int hashCode() {
163                return getTagName().hashCode();
164        }
165        
166        /**
167         * Returns a key to use for tag when getting / setting comment related attributes
168         * @param type
169         * @param member
170         * @return a new key that can be used for map lookups
171         */
172        private Integer getTagKey(int type, int member) {
173                return new Integer((type | member) + hashCode());
174        }
175}

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