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

COVERAGE SUMMARY FOR SOURCE FILE [Factory.java]

nameclass, %method, %block, %line, %
Factory.java100% (1/1)89%  (8/9)96%  (78/81)94%  (16/17)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Factory100% (1/1)89%  (8/9)96%  (78/81)94%  (16/17)
Factory (): void 0%   (0/1)0%   (0/3)0%   (0/1)
componentDescriptor (String): IComponentDescriptor 100% (1/1)100% (6/6)100% (1/1)
componentDescriptor (String, String): IComponentDescriptor 100% (1/1)100% (6/6)100% (1/1)
fieldDescriptor (String, String): IFieldDescriptor 100% (1/1)100% (7/7)100% (2/2)
methodDescriptor (String, String, String): IMethodDescriptor 100% (1/1)100% (8/8)100% (2/2)
newScope (IApiComponent []): IApiTypeContainer 100% (1/1)100% (29/29)100% (5/5)
newTypeScope (IApiComponent, IReferenceTypeDescriptor []): IApiTypeContainer 100% (1/1)100% (6/6)100% (1/1)
packageDescriptor (String): IPackageDescriptor 100% (1/1)100% (5/5)100% (1/1)
typeDescriptor (String): IReferenceTypeDescriptor 100% (1/1)100% (11/11)100% (3/3)

1/*******************************************************************************
2 * Copyright (c) 2007, 2009 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.provisional;
12 
13 
14import java.util.LinkedList;
15import java.util.List;
16 
17import org.eclipse.core.runtime.CoreException;
18import org.eclipse.pde.api.tools.internal.builder.TypeScope;
19import org.eclipse.pde.api.tools.internal.descriptors.ComponentDescriptorImpl;
20import org.eclipse.pde.api.tools.internal.descriptors.PackageDescriptorImpl;
21import org.eclipse.pde.api.tools.internal.model.CompositeApiTypeContainer;
22import org.eclipse.pde.api.tools.internal.provisional.descriptors.IComponentDescriptor;
23import org.eclipse.pde.api.tools.internal.provisional.descriptors.IFieldDescriptor;
24import org.eclipse.pde.api.tools.internal.provisional.descriptors.IMethodDescriptor;
25import org.eclipse.pde.api.tools.internal.provisional.descriptors.IPackageDescriptor;
26import org.eclipse.pde.api.tools.internal.provisional.descriptors.IReferenceTypeDescriptor;
27import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
28import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeContainer;
29import org.eclipse.pde.api.tools.internal.util.Signatures;
30 
31/**
32 * Factory to create API model objects.
33 * 
34 * @since 1.0
35 */
36public class Factory {
37 
38        /**
39         * Returns a component descriptor for the {@link IApiComponent} with the given id
40         * and an undefined version.
41         * The given id does not have to be the id of a component that actually exists: no
42         * resolution or lookup of any kind is done with the descriptor.
43         * 
44         * @param componentid
45         * @return a new component descriptor
46         */
47        public static IComponentDescriptor componentDescriptor(String componentid) {
48                return new ComponentDescriptorImpl(componentid, null);
49        }
50        
51        /**
52         * Returns a component descriptor for the {@link IApiComponent} with the given id and version.
53         * The given id does not have to be the id of a component that actually exists: no
54         * resolution or lookup of any kind is done with the descriptor.
55         * 
56         * @param componentid
57         * @param version version descriptor or <code>null</code> if none
58         * @return a new component descriptor
59         */
60        public static IComponentDescriptor componentDescriptor(String componentid, String version) {
61                return new ComponentDescriptorImpl(componentid, version);
62        }        
63        
64        /**
65         * Returns a package descriptor for the package with the given name.
66         * An empty string indicates the default package. Package names are
67         * dot qualified.
68         *  
69         * @param packageName package name
70         * @return an {@link IPackageDescriptor} for the package
71         */
72        public static IPackageDescriptor packageDescriptor(String packageName) {
73                return new PackageDescriptorImpl(packageName);
74        }
75        
76        /**
77         * Utility method to create a type descriptor for a type with the
78         * given fully qualified name. Package names are dot qualified and
79         * type names are '$'-qualified.
80         * 
81         * @param fullyQualifiedName
82         * @return an {@link ITypeDescriptor} for the type
83         */
84        public static IReferenceTypeDescriptor typeDescriptor(String fullyQualifiedName) {
85                String packageName = Signatures.getPackageName(fullyQualifiedName);
86                String typeName = Signatures.getTypeName(fullyQualifiedName);
87                return packageDescriptor(packageName).getType(typeName);
88        }
89        
90        /**
91         * Utility method to create a type descriptor for a method contained within the given 
92         * type
93         * 
94         * @param typename the name of the enclosing type for the method
95         * @param name the name of the method
96         * @param signaturethe signature of the method
97         * @return an {@link IMethodDescriptor} for the method
98         */
99        public static IMethodDescriptor methodDescriptor(String typename, String name, String signature) {
100                IReferenceTypeDescriptor type = typeDescriptor(typename);
101                return type.getMethod(name, signature);
102        }
103        
104        /**
105         * Utility method to create a type descriptor for a field contained within the given type
106         * 
107         * @param typename the name of the enclosing type for the field
108         * @param name the name of the field
109         * @return an {@link IFieldDescriptor} for the field
110         */
111        public static IFieldDescriptor fieldDescriptor(String typename , String name) {
112                IReferenceTypeDescriptor type = typeDescriptor(typename);
113                return type.getField(name);
114        }
115        
116        /**
117         * Returns a scope containing all elements in the given components.
118         * 
119         * @param components API components
120         * @return search scope
121         * @throws CoreException if the baseline of the given components is disposed
122         */
123        public static IApiTypeContainer newScope(IApiComponent[] components) throws CoreException {
124                List compList = new LinkedList();
125                for (int i = 0; i < components.length; i++) {
126                        compList.add(components[i]);
127                }
128                CompositeApiTypeContainer scope = new CompositeApiTypeContainer(components[0].getBaseline(), compList);
129                return scope;
130        }
131        
132        /**
133         * Returns a new scope containing the specified types in the given component.
134         * 
135         * @param component API component
136         * @param types reference types
137         * @return search scope
138         */
139        public static IApiTypeContainer newTypeScope(IApiComponent component, IReferenceTypeDescriptor[] types) {
140                return new TypeScope(component, types);
141        }
142}
143 

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