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

nameclass, %method, %block, %line, %
ResourceApiTypeRoot.java100% (1/1)50%  (3/6)30%  (24/79)32%  (6.4/20)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ResourceApiTypeRoot100% (1/1)50%  (3/6)30%  (24/79)32%  (6.4/20)
equals (Object): boolean 0%   (0/1)0%   (0/16)0%   (0/4)
hashCode (): int 0%   (0/1)0%   (0/4)0%   (0/1)
toString (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getContents (): byte [] 100% (1/1)29%  (13/45)24%  (2.4/10)
ResourceApiTypeRoot (IApiElement, IFile, String): void 100% (1/1)100% (8/8)100% (3/3)
getTypeName (): String 100% (1/1)100% (3/3)100% (1/1)

1/*******************************************************************************
2 * Copyright (c) 2008, 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 java.io.IOException;
14import java.io.InputStream;
15 
16import org.eclipse.core.resources.IFile;
17import org.eclipse.core.runtime.CoreException;
18import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
19import org.eclipse.pde.api.tools.internal.provisional.model.IApiElement;
20import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeRoot;
21import org.eclipse.pde.api.tools.internal.util.Util;
22 
23/**
24 * A class file corresponding to a resource in the workspace.
25 * 
26 * @since 1.0
27 */
28public class ResourceApiTypeRoot extends AbstractApiTypeRoot {
29        
30        /**
31         * Corresponding file
32         */
33        private IFile fFile;
34 
35        /**
36         * Constructs an {@link IApiTypeRoot} on the underlying file.
37         * 
38         * @param parent the {@link IApiElement} parent or <code>null</code> if none
39         * @param file underlying resource
40         * @param component API component the class file originates from
41         */
42        public ResourceApiTypeRoot(IApiElement parent, IFile file, String typeName) {
43                super(parent, typeName);
44                fFile = file;
45        }
46 
47        /* (non-Javadoc)
48         * @see org.eclipse.pde.api.tools.internal.model.AbstractApiTypeRoot#getContents()
49         */
50        public byte[] getContents() throws CoreException {
51                InputStream stream = fFile.getContents();
52                try {
53                        return Util.getInputStreamAsByteArray(stream, -1);
54                }
55                catch (IOException ioe) {
56                        abort("Unable to read class file: " + getTypeName(), ioe); //$NON-NLS-1$
57                        return null;
58                }
59                finally {
60                        try {
61                                stream.close();
62                        } catch (IOException e) {
63                                ApiPlugin.log(e);
64                        }
65                }
66        }
67        
68        /* (non-Javadoc)
69         * @see org.eclipse.pde.api.tools.internal.provisional.IApiTypeRoot#getTypeName()
70         */
71        public String getTypeName() {
72                return getName();
73        }
74 
75        /* (non-Javadoc)
76         * @see java.lang.Object#toString()
77         */
78        public String toString() {
79                return getTypeName();
80        }
81        
82        /* (non-Javadoc)
83         * @see java.lang.Object#hashCode()
84         */
85        public int hashCode() {
86                return getName().hashCode();
87        }
88        
89        /* (non-Javadoc)
90         * @see java.lang.Object#equals(java.lang.Object)
91         */
92        public boolean equals(Object obj) {
93                if(obj instanceof IApiTypeRoot) {
94                        IApiTypeRoot file = (IApiTypeRoot) obj;
95                        return getName().equals(file.getTypeName());
96                }
97                return super.equals(obj);
98        }
99}

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