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

nameclass, %method, %block, %line, %
ApiField.java100% (1/1)57%  (4/7)32%  (37/116)28%  (9/32)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ApiField100% (1/1)57%  (4/7)32%  (37/116)28%  (9/32)
equals (Object): boolean 0%   (0/1)0%   (0/9)0%   (0/3)
hashCode (): int 0%   (0/1)0%   (0/12)0%   (0/1)
toString (): String 0%   (0/1)0%   (0/57)0%   (0/18)
getHandle (): IMemberDescriptor 100% (1/1)95%  (18/19)80%  (4/5)
ApiField (IApiType, String, String, String, int, Object): void 100% (1/1)100% (12/12)100% (3/3)
getConstantValue (): Object 100% (1/1)100% (3/3)100% (1/1)
isEnumConstant (): boolean 100% (1/1)100% (4/4)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 org.eclipse.core.runtime.CoreException;
14import org.eclipse.jdt.core.Flags;
15import org.eclipse.pde.api.tools.internal.provisional.descriptors.IFieldDescriptor;
16import org.eclipse.pde.api.tools.internal.provisional.descriptors.IMemberDescriptor;
17import org.eclipse.pde.api.tools.internal.provisional.descriptors.IReferenceTypeDescriptor;
18import org.eclipse.pde.api.tools.internal.provisional.model.IApiElement;
19import org.eclipse.pde.api.tools.internal.provisional.model.IApiField;
20import org.eclipse.pde.api.tools.internal.provisional.model.IApiType;
21import org.eclipse.pde.api.tools.internal.util.Util;
22 
23/**
24 * Base implementation of {@link IApiField}
25 * 
26 * @since 1.0.0
27 * @noextend This class is not intended to be subclassed by clients.
28 * @noinstantiate This class is not intended to be instantiated by clients.
29 */
30public class ApiField extends ApiMember implements IApiField {
31        
32        /**
33         * Constant value
34         */
35        private Object fValue;
36        
37        private IFieldDescriptor fHandle;
38        
39        /**
40         * Constructor
41         * @param parent the enclosing type of the field
42         * @param name the name of the field
43         * @param signature the signature for the field
44         * @param genericSig the generic signature of the field
45         * @param flags the flags for the field
46         * @param value the value assigned to the field
47         * @param value constant value or <code>null</code> if none
48         */
49        protected ApiField(IApiType enclosing, String name, String signature, String genericSig, int flags, Object value) {
50                super(enclosing, name, signature, genericSig, IApiElement.FIELD, flags);
51                fValue = value;
52        }
53        
54        /**
55         * @see org.eclipse.pde.api.tools.internal.provisional.model.IApiField#isEnumConstant()
56         */
57        public boolean isEnumConstant() {
58                return (Flags.isEnum(getModifiers()));
59        }
60        
61        /* (non-Javadoc)
62         * @see org.eclipse.pde.api.tools.internal.model.ApiMember#equals(java.lang.Object)
63         */
64        public boolean equals(Object obj) {
65                if (obj instanceof IApiField) {
66                        return super.equals(obj);
67                }
68                return false;
69        }
70 
71        public int hashCode() {
72                return super.hashCode() + (this.fValue != null ? this.fValue.hashCode() : 0);
73        }
74 
75        /* (non-Javadoc)
76         * @see org.eclipse.pde.api.tools.internal.provisional.model.IApiField#getConstantValue()
77         */
78        public Object getConstantValue() {
79                return fValue;
80        }
81        
82        public String toString() {
83                StringBuffer buffer = new StringBuffer();
84                buffer
85                        .append("Field : access(") //$NON-NLS-1$
86                        .append(getModifiers())
87                        .append(") ") //$NON-NLS-1$
88                        .append(getSignature())
89                        .append(' ')
90                        .append(getName())
91                        .append(" isEnum constant ") //$NON-NLS-1$
92                        .append(isEnumConstant());
93                if (getConstantValue() != null) {
94                        buffer.append(" = ").append(getConstantValue()); //$NON-NLS-1$
95                }
96                buffer.append(';').append(Util.LINE_DELIMITER);
97                if (getGenericSignature() != null) {
98                        buffer
99                                .append(" Signature : ") //$NON-NLS-1$
100                                .append(getGenericSignature()).append(Util.LINE_DELIMITER);
101                }
102                return String.valueOf(buffer);
103        }        
104        
105        /* (non-Javadoc)
106         * @see org.eclipse.pde.api.tools.internal.provisional.model.IApiMember#getHandle()
107         */
108        public IMemberDescriptor getHandle() {
109                if (fHandle == null) {
110                        try {
111                                IApiType type = getEnclosingType();
112                                fHandle = ((IReferenceTypeDescriptor)type.getHandle()).getField(getName());
113                        } catch (CoreException e) {
114                                // should not happen for field or method - enclosing type is cached
115                        }
116                }
117                return fHandle;
118        }
119}

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