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

COVERAGE SUMMARY FOR SOURCE FILE [ApiProblemFilter.java]

nameclass, %method, %block, %line, %
ApiProblemFilter.java100% (1/1)100% (9/9)98%  (166/170)99%  (35.5/36)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ApiProblemFilter100% (1/1)100% (9/9)98%  (166/170)99%  (35.5/36)
elementsEqual (Object, Object): boolean 100% (1/1)86%  (12/14)85%  (0.8/1)
equals (Object): boolean 100% (1/1)94%  (33/35)95%  (6.6/7)
ApiProblemFilter (String, IApiProblem): void 100% (1/1)100% (17/17)100% (7/7)
clone (): Object 100% (1/1)100% (8/8)100% (1/1)
getComponentId (): String 100% (1/1)100% (3/3)100% (1/1)
getHandle (): String 100% (1/1)100% (65/65)100% (13/13)
getUnderlyingProblem (): IApiProblem 100% (1/1)100% (3/3)100% (1/1)
hashCode (): int 100% (1/1)100% (8/8)100% (1/1)
toString (): String 100% (1/1)100% (17/17)100% (4/4)

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.problems;
12 
13import org.eclipse.core.runtime.Assert;
14import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem;
15import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblemFilter;
16 
17/**
18 * Base implementation of {@link IApiProblemFilter}
19 * 
20 * @since 1.0.0
21 */
22public class ApiProblemFilter implements IApiProblemFilter, Cloneable {
23 
24        public static final String HANDLE_ARGUMENTS_DELIMITER = ","; //$NON-NLS-1$
25        public static final String HANDLE_DELIMITER = "%]"; //$NON-NLS-1$
26 
27        private String fComponentId = null;
28        private IApiProblem fProblem = null;
29        
30        /**
31         * Constructor
32         * 
33         * @param componentid
34         * @param problem
35         */
36        public ApiProblemFilter(String componentid, IApiProblem problem) {
37                fComponentId = componentid;
38                Assert.isNotNull(problem);
39                fProblem = problem;
40        }
41        
42        /* (non-Javadoc)
43         * @see org.eclipse.pde.api.tools.IApiProblemFilter#getComponentId()
44         */
45        public String getComponentId() {
46                return fComponentId;
47        }
48        
49        /* (non-Javadoc)
50         * @see java.lang.Object#equals(java.lang.Object)
51         */
52        public boolean equals(Object obj) {
53                if(obj instanceof IApiProblemFilter) {
54                        IApiProblemFilter filter = (IApiProblemFilter) obj;
55                        return elementsEqual(filter.getComponentId(), fComponentId) &&
56                                        filter.getUnderlyingProblem().equals(fProblem);
57                }
58                else if(obj instanceof IApiProblem) {
59                        return fProblem.equals(obj);
60                }
61                return super.equals(obj);
62        }
63        
64        /* (non-Javadoc)
65         * @see java.lang.Object#hashCode()
66         */
67        public int hashCode() {
68                return fProblem.hashCode() + fComponentId.hashCode();
69        }
70        
71        /**
72         * Returns if the two specified objects are equal.
73         * Objects are considered equal if:
74         * <ol>
75         * <li>they are both null</li>
76         * <li>they are equal via the default .equals() method</li>
77         * </ol>
78         * @param s1
79         * @param s2
80         * @return true if the objects are equal, false otherwise
81         */
82        private boolean elementsEqual(Object s1, Object s2) {
83                return (s1 == null && s2 == null) || (s1 != null && s1.equals(s2));
84        }
85        
86        /* (non-Javadoc)
87         * @see java.lang.Object#toString()
88         */
89        public String toString() {
90                StringBuffer buffer = new StringBuffer();
91                buffer.append("Filter for : "); //$NON-NLS-1$
92                buffer.append(fProblem.toString());
93                return buffer.toString();
94        }
95        
96        /* (non-Javadoc)
97         * @see java.lang.Object#clone()
98         */
99        public Object clone() {
100                return new ApiProblemFilter(this.fComponentId, fProblem);
101        }
102 
103        /* (non-Javadoc)
104         * @see org.eclipse.pde.api.tools.internal.provisional.IApiProblemFilter#getUnderlyingProblem()
105         */
106        public IApiProblem getUnderlyingProblem() {
107                return fProblem;
108        }
109        
110        /**
111         * @return returns a handle that can be used to identify the filter
112         */
113        public String getHandle() {
114                StringBuffer buffer = new StringBuffer();
115                buffer.append(fProblem.getId());
116                buffer.append(HANDLE_DELIMITER);
117                buffer.append(fProblem.getResourcePath());
118                buffer.append(HANDLE_DELIMITER);
119                buffer.append(fProblem.getTypeName());
120                buffer.append(HANDLE_DELIMITER);
121                String[] margs = fProblem.getMessageArguments();
122                for(int i = 0; i < margs.length; i++) {
123                        buffer.append(margs[i]);
124                        if(i < margs.length-1) {
125                                buffer.append(HANDLE_ARGUMENTS_DELIMITER);
126                        }
127                }
128                return buffer.toString();
129        }
130}

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