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

COVERAGE SUMMARY FOR SOURCE FILE [ReferenceTypeDescriptorImpl.java]

nameclass, %method, %block, %line, %
ReferenceTypeDescriptorImpl.java100% (1/1)86%  (12/14)89%  (162/182)85%  (44/52)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ReferenceTypeDescriptorImpl100% (1/1)86%  (12/14)89%  (162/182)85%  (44/52)
ReferenceTypeDescriptorImpl (String, IElementDescriptor, String): void 0%   (0/1)0%   (0/8)0%   (0/3)
isAnonymous (): boolean 0%   (0/1)0%   (0/12)0%   (0/5)
ReferenceTypeDescriptorImpl (String, IElementDescriptor): void 100% (1/1)100% (14/14)100% (5/5)
equals (Object): boolean 100% (1/1)100% (14/14)100% (4/4)
getComparable (): Comparable 100% (1/1)100% (3/3)100% (1/1)
getElementType (): int 100% (1/1)100% (2/2)100% (1/1)
getField (String): IFieldDescriptor 100% (1/1)100% (6/6)100% (1/1)
getGenericSignature (): String 100% (1/1)100% (3/3)100% (1/1)
getMethod (String, String): IMethodDescriptor 100% (1/1)100% (7/7)100% (1/1)
getQualifiedName (): String 100% (1/1)100% (73/73)100% (20/20)
getSignature (): String 100% (1/1)100% (27/27)100% (7/7)
getType (String): IReferenceTypeDescriptor 100% (1/1)100% (6/6)100% (1/1)
hashCode (): int 100% (1/1)100% (4/4)100% (1/1)
toString (): String 100% (1/1)100% (3/3)100% (1/1)

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.descriptors;
12 
13import java.util.ArrayList;
14import java.util.Iterator;
15import java.util.List;
16 
17import org.eclipse.pde.api.tools.internal.provisional.descriptors.IElementDescriptor;
18import org.eclipse.pde.api.tools.internal.provisional.descriptors.IFieldDescriptor;
19import org.eclipse.pde.api.tools.internal.provisional.descriptors.IMethodDescriptor;
20import org.eclipse.pde.api.tools.internal.provisional.descriptors.IReferenceTypeDescriptor;
21 
22/**
23 * Reference type descriptor.
24 * 
25 * @since 1.0.0
26 */
27public class ReferenceTypeDescriptorImpl extends MemberDescriptorImpl implements IReferenceTypeDescriptor {
28        
29        /**
30         * Fully qualified name
31         */
32        private String fFullName = null;
33        
34        /**
35         * Type signature
36         */
37        private String fSignature = null;
38        
39        /**
40         * Generic information or <code>null</code>
41         */
42        private String fGenericSignature = null;
43 
44        /**
45         * Constructs a type descriptor with the given name and parent.
46         * 
47         * @param name simple type name
48         * @param parent package or enclosing type
49         */
50        ReferenceTypeDescriptorImpl(String name, IElementDescriptor parent) {
51                super(name, parent);
52                
53        }
54        
55        /**
56         * Constructs a type descriptor with the given name and parent.
57         * 
58         * @param name simple type name
59         * @param parent package or enclosing type
60         * @param genericSignature generic signature info or <code>null</code>
61         */
62        ReferenceTypeDescriptorImpl(String name, IElementDescriptor parent, String genericSignature) {
63                this(name, parent);
64                fGenericSignature = genericSignature;
65        }
66 
67        /* (non-Javadoc)
68         * @see org.eclipse.pde.api.tools.model.component.IReferenceTypeDescriptor#getField(java.lang.String)
69         */
70        public IFieldDescriptor getField(String name) {
71                return new FieldDescriptorImpl(name, this);
72        }
73 
74        /* (non-Javadoc)
75         * @see org.eclipse.pde.api.tools.model.component.IReferenceTypeDescriptor#getMethod(java.lang.String, java.lang.String)
76         */
77        public IMethodDescriptor getMethod(String name, String signature) {
78                return new MethodDescriptorImpl(name, this, signature);
79        }
80 
81        /* (non-Javadoc)
82         * @see org.eclipse.pde.api.tools.model.component.IReferenceTypeDescriptor#getType(java.lang.String)
83         */
84        public IReferenceTypeDescriptor getType(String simpleName) {
85                return new ReferenceTypeDescriptorImpl(simpleName, this);
86        }
87        
88        /* (non-Javadoc)
89         * @see java.lang.Object#toString()
90         */
91        public String toString() {
92                return getQualifiedName();
93        }        
94        
95        /* (non-Javadoc)
96         * @see org.eclipse.pde.api.tools.model.component.IReferenceTypeDescriptor#getQualifiedName()
97         */
98        public synchronized String getQualifiedName() {
99                if (fFullName == null) {
100                        StringBuffer buffer = new StringBuffer();
101                        buffer.append(getPackage().getName());
102                        if (buffer.length() > 0) {
103                                buffer.append('.');
104                        }
105                        List all = null;
106                        IReferenceTypeDescriptor enclosingType = getEnclosingType();
107                        while (enclosingType != null) {
108                                if (all == null) {
109                                        all = new ArrayList();
110                                }
111                                all.add(0, enclosingType);
112                                enclosingType = enclosingType.getEnclosingType();
113                        }
114                        if (all != null) {
115                                Iterator iterator = all.iterator();
116                                while (iterator.hasNext()) {
117                                        buffer.append(((IReferenceTypeDescriptor)iterator.next()).getName());
118                                        buffer.append('$');
119                                }
120                        }
121                        buffer.append(getName());
122                        fFullName = buffer.toString();
123                }
124                return fFullName;
125        }
126        
127        /* (non-Javadoc)
128         * @see java.lang.Object#equals(java.lang.Object)
129         */
130        public boolean equals(Object obj) {
131                if (obj instanceof IReferenceTypeDescriptor) {
132                        IReferenceTypeDescriptor refType = (IReferenceTypeDescriptor) obj;
133                        return getQualifiedName().equals(refType.getQualifiedName());
134                }
135                return false;
136        }
137        
138        /* (non-Javadoc)
139         * @see java.lang.Object#hashCode()
140         */
141        public int hashCode() {
142                return getQualifiedName().hashCode();
143        }                
144 
145        /* (non-Javadoc)
146         * @see org.eclipse.pde.api.tools.internal.descriptors.ElementDescriptorImpl#getComparable()
147         */
148        protected Comparable getComparable() {
149                return getQualifiedName();
150        }
151        
152        /* (non-Javadoc)
153         * @see org.eclipse.pde.api.tools.model.component.IElementDescriptor#getElementType()
154         */
155        public int getElementType() {
156                return IElementDescriptor.TYPE;
157        }
158        /* (non-Javadoc)
159         * @see org.eclipse.pde.api.tools.model.component.IReferenceTypeDescriptor#getSignature()
160         */
161        public String getSignature() {
162                if (fSignature == null) {
163                        StringBuffer buf = new StringBuffer();
164                        buf.append('L');
165                        buf.append(getQualifiedName());
166                        buf.append(';');
167                        fSignature = buf.toString();
168                }
169                return fSignature;
170        }
171 
172        /* (non-Javadoc)
173         * @see org.eclipse.pde.api.tools.model.component.IReferenceTypeDescriptor#getGenericSignature()
174         */
175        public String getGenericSignature() {
176                return fGenericSignature;
177        }
178 
179        /* (non-Javadoc)
180         * @see org.eclipse.pde.api.tools.descriptors.IReferenceTypeDescriptor#isAnonymous()
181         */
182        public boolean isAnonymous() {
183                if (getEnclosingType() != null) {
184                        try {
185                                Integer.parseInt(getName());
186                                return true;
187                        } catch (NumberFormatException e) {
188                        }
189                }
190                return false;
191        }
192 
193}

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