KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mountainminds > eclemma > internal > core > CoverageSession


1 /*******************************************************************************
2  * Copyright (c) 2006 Mountainminds GmbH & Co. KG
3  * This software is provided under the terms of the Eclipse Public License v1.0
4  * See http://www.eclipse.org/legal/epl-v10.html.
5  *
6  * $Id: CoverageSession.java 39 2006-08-31 20:37:49Z mho $
7  ******************************************************************************/

8 package com.mountainminds.eclemma.internal.core;
9
10 import java.util.ArrayList JavaDoc;
11 import java.util.Arrays JavaDoc;
12 import java.util.List JavaDoc;
13
14 import org.eclipse.core.runtime.IPath;
15 import org.eclipse.core.runtime.PlatformObject;
16 import org.eclipse.debug.core.ILaunchConfiguration;
17
18 import com.mountainminds.eclemma.core.ICoverageSession;
19 import com.mountainminds.eclemma.core.IInstrumentation;
20
21 /**
22  * A {@link com.mountainminds.eclemma.core.ICoverageSession} implementation.
23  *
24  * @author Marc R. Hoffmann
25  * @version $Revision: 39 $
26  */

27 public class CoverageSession extends PlatformObject implements ICoverageSession {
28
29   private final String JavaDoc description;
30
31   private final IInstrumentation[] instrumentations;
32
33   private final IPath[] coveragedatafiles;
34
35   private final ILaunchConfiguration launchconfiguration;
36
37   public CoverageSession(String JavaDoc description,
38       IInstrumentation[] instrumentations, IPath[] coveragedatafiles,
39       ILaunchConfiguration launchconfiguration) {
40     this.description = description;
41     this.instrumentations = instrumentations;
42     this.coveragedatafiles = coveragedatafiles;
43     this.launchconfiguration = launchconfiguration;
44   }
45
46   // ICoverageSession implementation
47

48   public String JavaDoc getDescription() {
49     return description;
50   }
51
52   public IInstrumentation[] getInstrumentations() {
53     return instrumentations;
54   }
55
56   public IPath[] getCoverageDataFiles() {
57     return this.coveragedatafiles;
58   }
59
60   public ILaunchConfiguration getLaunchConfiguration() {
61     return launchconfiguration;
62   }
63
64   public ICoverageSession merge(ICoverageSession other, String JavaDoc description) {
65     List JavaDoc i = merge(instrumentations, other.getInstrumentations());
66     List JavaDoc c = merge(coveragedatafiles, other.getCoverageDataFiles());
67     return new CoverageSession(description,
68         (IInstrumentation[]) i.toArray(new IInstrumentation[i.size()]),
69         (IPath[]) c.toArray(new IPath[c.size()]), launchconfiguration);
70   }
71
72   private List JavaDoc merge(Object JavaDoc[] arr1, Object JavaDoc[] arr2) {
73     List JavaDoc l = new ArrayList JavaDoc(Arrays.asList(arr1));
74     for (int i = 0; i < arr2.length; i++) {
75       if (!l.contains(arr2[i])) {
76         l.add(arr2[i]);
77       }
78     }
79     return l;
80   }
81
82 }
83
Popular Tags