587
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
package com.nokia.helium.ant.coverage;
|
|
18 |
|
|
19 |
import java.util.Vector;
|
|
20 |
|
|
21 |
/**
|
|
22 |
* To store antmacro information.
|
|
23 |
*/
|
|
24 |
public class AntMacros {
|
|
25 |
private Vector<MacroHolder> antMacros = new Vector<MacroHolder>();
|
|
26 |
|
|
27 |
/**
|
|
28 |
* To add macro.
|
|
29 |
*
|
|
30 |
* @param macro
|
|
31 |
*/
|
|
32 |
public void add(String macro) {
|
|
33 |
for (MacroHolder mh : antMacros) {
|
628
|
34 |
if (mh.equals(macro)) {
|
587
|
35 |
return;
|
628
|
36 |
}
|
587
|
37 |
}
|
|
38 |
this.antMacros.add(new MacroHolder(macro));
|
|
39 |
}
|
|
40 |
|
|
41 |
/**
|
|
42 |
* To get number of ant macros.
|
|
43 |
*
|
|
44 |
* @return
|
|
45 |
*/
|
|
46 |
public int getCount() {
|
|
47 |
return this.antMacros.size();
|
|
48 |
}
|
|
49 |
|
|
50 |
/**
|
|
51 |
* To check is the macro present in the list.
|
|
52 |
*
|
|
53 |
* @param macroName
|
|
54 |
* @return
|
|
55 |
*/
|
|
56 |
public boolean isMacroPresent(String macroName) {
|
|
57 |
return antMacros.contains(macroName);
|
|
58 |
}
|
|
59 |
|
|
60 |
/**
|
|
61 |
*
|
|
62 |
* @param targetName
|
|
63 |
*/
|
|
64 |
public void markAsExecuted(String targetName) {
|
|
65 |
for (MacroHolder mh : antMacros) {
|
|
66 |
if (mh.equals(targetName)) {
|
|
67 |
mh.markAsExecuted();
|
|
68 |
return;
|
|
69 |
}
|
|
70 |
}
|
|
71 |
}
|
|
72 |
|
|
73 |
/**
|
|
74 |
* The count of distinct executed target.
|
|
75 |
*
|
|
76 |
* @return the number of distinct executed target.
|
|
77 |
*/
|
|
78 |
public int getExecutedCount() {
|
|
79 |
int count = 0;
|
|
80 |
for (MacroHolder mh : antMacros) {
|
|
81 |
if (mh.isExecuted()) {
|
|
82 |
count++;
|
|
83 |
}
|
|
84 |
}
|
|
85 |
return count;
|
|
86 |
}
|
|
87 |
|
|
88 |
/**
|
|
89 |
* Holder class to contains macro related informations.
|
|
90 |
*
|
|
91 |
*/
|
|
92 |
public class MacroHolder {
|
|
93 |
private String name;
|
|
94 |
private boolean executed;
|
|
95 |
|
|
96 |
/**
|
|
97 |
* Create a scripdef holder.
|
|
98 |
*
|
|
99 |
* @param name
|
|
100 |
*/
|
|
101 |
public MacroHolder(String name) {
|
|
102 |
this.name = name;
|
|
103 |
}
|
|
104 |
|
|
105 |
/**
|
|
106 |
* Is this holder matching a particular object.
|
|
107 |
*/
|
|
108 |
public boolean equals(Object obj) {
|
|
109 |
return this.name.equals(obj);
|
|
110 |
}
|
|
111 |
|
|
112 |
/**
|
|
113 |
* {@inheritDoc}
|
|
114 |
*/
|
|
115 |
public int hashCode() {
|
|
116 |
return super.hashCode();
|
|
117 |
}
|
|
118 |
|
|
119 |
/**
|
|
120 |
* Mark as executed.
|
|
121 |
*/
|
|
122 |
public void markAsExecuted() {
|
|
123 |
this.executed = true;
|
|
124 |
}
|
|
125 |
|
|
126 |
/**
|
|
127 |
* As this target been executing?
|
|
128 |
*/
|
|
129 |
public boolean isExecuted() {
|
|
130 |
return executed;
|
|
131 |
}
|
|
132 |
}
|
|
133 |
|
|
134 |
}
|