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 |
|
|
18 |
package com.nokia.helium.imaker.ant.types;
|
|
19 |
import java.util.Hashtable;
|
|
20 |
import java.util.Map;
|
|
21 |
import java.util.Vector;
|
|
22 |
|
628
|
23 |
import org.apache.tools.ant.types.DataType;
|
|
24 |
|
587
|
25 |
/**
|
|
26 |
* This type is a container for variable configuration.
|
|
27 |
*
|
|
28 |
* <pre>
|
|
29 |
* <variableset>
|
|
30 |
* <variable name="TYPE" value="rnd" />
|
|
31 |
* </variableset>
|
|
32 |
* </pre>
|
|
33 |
*
|
|
34 |
* @ant.type name="variableset" category="imaker"
|
|
35 |
*/
|
|
36 |
public class VariableSet extends DataType {
|
|
37 |
|
|
38 |
private Vector<Variable> variables = new Vector<Variable>();
|
|
39 |
|
|
40 |
/**
|
|
41 |
* Creates a Variable object.
|
|
42 |
* @return a Variable object.
|
|
43 |
*/
|
|
44 |
public Variable createVariable() {
|
|
45 |
Variable var = new Variable();
|
|
46 |
add(var);
|
|
47 |
return var;
|
|
48 |
}
|
|
49 |
|
|
50 |
/**
|
|
51 |
* Support the addition of a Variable object.
|
|
52 |
* @param a Variable object.
|
|
53 |
*/
|
|
54 |
public void add(Variable var) {
|
|
55 |
variables.add(var);
|
|
56 |
}
|
|
57 |
|
|
58 |
/**
|
|
59 |
* Get the list of Variable object.
|
|
60 |
* @return a vector of Variable objects
|
|
61 |
*/
|
|
62 |
public Vector<Variable> getVariables() {
|
|
63 |
return variables;
|
|
64 |
}
|
|
65 |
|
|
66 |
/**
|
|
67 |
* Convert the set of variable to a Map object.
|
|
68 |
* @return the content of that set into a Map object.
|
|
69 |
*/
|
|
70 |
public Map<String, String> toMap() {
|
|
71 |
Map<String, String> data = new Hashtable<String, String>();
|
|
72 |
for (Variable var : variables) {
|
|
73 |
var.validate();
|
|
74 |
data.put(var.getName(), var.getValue());
|
|
75 |
}
|
|
76 |
return data;
|
|
77 |
}
|
|
78 |
}
|