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

COVERAGE SUMMARY FOR SOURCE FILE [AbstractApiComponent.java]

nameclass, %method, %block, %line, %
AbstractApiComponent.java100% (1/1)80%  (12/15)83%  (86/104)81%  (25/31)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AbstractApiComponent100% (1/1)80%  (12/15)83%  (86/104)81%  (25/31)
getContainerType (): int 0%   (0/1)0%   (0/2)0%   (0/1)
getHost (): IApiComponent 0%   (0/1)0%   (0/2)0%   (0/1)
isApiDescriptionInitialized (): boolean 0%   (0/1)0%   (0/7)0%   (0/1)
getApiTypeContainers (String): IApiTypeContainer [] 100% (1/1)60%  (6/10)67%  (2/3)
dispose (): void 100% (1/1)70%  (7/10)60%  (3/5)
AbstractApiComponent (IApiBaseline): void 100% (1/1)100% (12/12)100% (4/4)
accept (ApiTypeContainerVisitor): void 100% (1/1)100% (11/11)100% (4/4)
getApiComponent (): IApiComponent 100% (1/1)100% (2/2)100% (1/1)
getApiDescription (): IApiDescription 100% (1/1)100% (10/10)100% (3/3)
getApiTypeContainers (): IApiTypeContainer [] 100% (1/1)100% (3/3)100% (1/1)
getBaseline (): IApiBaseline 100% (1/1)100% (5/5)100% (1/1)
getFilterStore (): IApiFilterStore 100% (1/1)100% (10/10)100% (3/3)
getHandle (): IElementDescriptor 100% (1/1)100% (6/6)100% (1/1)
hasApiFilterStore (): boolean 100% (1/1)100% (7/7)100% (1/1)
newProblemFilter (IApiProblem): IApiProblemFilter 100% (1/1)100% (7/7)100% (1/1)

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.model;
12 
13import org.eclipse.core.runtime.CoreException;
14import org.eclipse.pde.api.tools.internal.problems.ApiProblemFilter;
15import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
16import org.eclipse.pde.api.tools.internal.provisional.Factory;
17import org.eclipse.pde.api.tools.internal.provisional.IApiDescription;
18import org.eclipse.pde.api.tools.internal.provisional.IApiFilterStore;
19import org.eclipse.pde.api.tools.internal.provisional.descriptors.IElementDescriptor;
20import org.eclipse.pde.api.tools.internal.provisional.model.ApiTypeContainerVisitor;
21import org.eclipse.pde.api.tools.internal.provisional.model.IApiBaseline;
22import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
23import org.eclipse.pde.api.tools.internal.provisional.model.IApiElement;
24import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeContainer;
25import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem;
26import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblemFilter;
27 
28/**
29 * Common implementation of an API component as a composite class file container.
30 * 
31 * @since 1.0.0
32 */
33public abstract class AbstractApiComponent extends AbstractApiTypeContainer implements IApiComponent {
34        /**
35         * API description
36         */
37        private IApiDescription fApiDescription = null;
38                
39        /**
40         * Api Filter store
41         */
42        private IApiFilterStore fFilterStore = null;
43        
44        /**
45         * Constructs an API component in the given {@link IApiBaseline}.
46         * 
47         * @param baseline the parent {@link IApiBaseline}
48         */
49        public AbstractApiComponent(IApiBaseline baseline) {
50                super(baseline, IApiElement.COMPONENT, null);
51        }
52        
53        /* (non-Javadoc)
54         * @see org.eclipse.pde.api.tools.model.component.IClassFileContainer#accept(org.eclipse.pde.api.tools.model.component.ClassFileContainerVisitor)
55         */
56        public void accept(ApiTypeContainerVisitor visitor) throws CoreException {
57                if (visitor.visit(this)) {
58                        super.accept(visitor);
59                }
60                visitor.end(this);
61        }        
62                
63        /**
64         * @see org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent#getHost()
65         */
66        public IApiComponent getHost() throws CoreException {
67                return null;
68        }
69        
70        /**
71         * @see org.eclipse.pde.api.tools.internal.provisional.IApiComponent#getBaseline()
72         */
73        public IApiBaseline getBaseline() {
74                return (IApiBaseline) getAncestor(IApiElement.BASELINE);
75        }
76 
77        /* (non-Javadoc)
78         * @see org.eclipse.pde.api.tools.model.component.IApiComponent#dispose()
79         */
80        public void dispose() {
81                try {
82                        close();
83                } catch (CoreException e) {
84                        ApiPlugin.log(e);
85                }
86                fApiDescription = null;
87        }
88 
89        /* (non-Javadoc)
90         * @see org.eclipse.pde.api.tools.internal.model.ApiElement#getApiComponent()
91         */
92        public IApiComponent getApiComponent() {
93                return this;
94        }
95        
96        /* (non-Javadoc)
97         * @see org.eclipse.pde.api.tools.model.component.IApiComponent#getApiDescription()
98         */
99        public synchronized IApiDescription getApiDescription() throws CoreException {
100                if (fApiDescription == null) {
101                        fApiDescription = createApiDescription();
102                }
103                return fApiDescription;
104        }
105        
106        /**
107         * Returns whether this component has created an API description.
108         * 
109         * @return whether this component has created an API description
110         */
111        protected synchronized boolean isApiDescriptionInitialized() {
112                return fApiDescription != null;
113        }
114 
115        /**
116         * Returns if this component has created an API filter store
117         * 
118         * @return true if a store has been created, false other wise
119         */
120        protected synchronized boolean hasApiFilterStore() {
121                return fFilterStore != null;
122        }
123        
124        /* (non-Javadoc)
125         * @see org.eclipse.pde.api.tools.internal.model.AbstractApiTypeContainer#getApiTypeContainers()
126         */
127        public synchronized IApiTypeContainer[] getApiTypeContainers() throws CoreException {
128                return super.getApiTypeContainers();
129        }
130 
131        /* (non-Javadoc)
132         * @see org.eclipse.pde.api.tools.internal.model.AbstractApiTypeContainer#getApiTypeContainers()
133         */
134        public synchronized IApiTypeContainer[] getApiTypeContainers(String id) throws CoreException {
135                if (this.hasFragments()) {
136                        return super.getApiTypeContainers(id);
137                } else {
138                        return super.getApiTypeContainers();
139                }
140        }
141        
142        /**
143         * Creates and returns the API description for this component.
144         * 
145         * @return newly created API description for this component
146         */
147        protected abstract IApiDescription createApiDescription() throws CoreException;
148 
149        /* (non-Javadoc)
150         * @see org.eclipse.pde.api.tools.IApiComponent#getFilterStore()
151         */
152        public IApiFilterStore getFilterStore() throws CoreException {
153                if(fFilterStore == null) {
154                        fFilterStore = createApiFilterStore();
155                }
156                return fFilterStore;
157        }
158 
159        /* (non-Javadoc)
160         * @see org.eclipse.pde.api.tools.internal.provisional.IApiComponent#newProblemFilter(org.eclipse.pde.api.tools.internal.provisional.IApiProblem)
161         */
162        public IApiProblemFilter newProblemFilter(IApiProblem problem) throws CoreException {
163                //TODO either expose a way to make problems or change the method to accept the parts of a problem
164                return new ApiProblemFilter(getId(), problem);
165        }
166        
167        /* (non-Javadoc)
168         * @see org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent#getHandle()
169         */
170        public IElementDescriptor getHandle() {
171                return Factory.componentDescriptor(this.getId(), this.getVersion());
172        }
173        
174        /* (non-Javadoc)
175         * @see org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeContainer#getContainerType()
176         */
177        public int getContainerType() {
178                return IApiTypeContainer.COMPONENT;
179        }
180        
181        /**
182         * Lazily creates a new {@link IApiFilterStore} when it is requested
183         * 
184         * @return the current {@link IApiFilterStore} for this component
185         * @throws CoreException
186         */
187        protected abstract IApiFilterStore createApiFilterStore() throws CoreException;        
188}

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