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.ant.data;
|
|
19 |
|
|
20 |
import java.util.List;
|
|
21 |
|
|
22 |
import org.dom4j.Element;
|
|
23 |
import org.dom4j.Node;
|
|
24 |
|
|
25 |
/**
|
|
26 |
* An Ant macro.
|
|
27 |
*/
|
|
28 |
public class MacroMeta extends TaskContainerMeta {
|
|
29 |
|
628
|
30 |
public MacroMeta(AntObjectMeta parent, Element objNode) {
|
587
|
31 |
super(parent, objNode);
|
|
32 |
}
|
|
33 |
|
|
34 |
public String getDescription() {
|
|
35 |
return getAttr("description");
|
|
36 |
}
|
|
37 |
|
|
38 |
@SuppressWarnings("unchecked")
|
|
39 |
public String getUsage() {
|
|
40 |
String macroName = getName();
|
|
41 |
List<Node> statements = getNode().selectNodes(
|
|
42 |
"//scriptdef[@name='" + macroName + "']/attribute | //macrodef[@name='" + macroName + "']/attribute");
|
|
43 |
String usage = "";
|
|
44 |
for (Node statement : statements) {
|
|
45 |
String defaultval = statement.valueOf("@default");
|
|
46 |
if (defaultval.equals("")) {
|
|
47 |
defaultval = "value";
|
|
48 |
}
|
588
|
49 |
// else {
|
|
50 |
// defaultval = "<i>" + defaultval + "</i>";
|
|
51 |
// }
|
587
|
52 |
usage = usage + statement.valueOf("@name") + "=\"" + defaultval + "\"" + " ";
|
|
53 |
}
|
|
54 |
|
|
55 |
String macroElements = "";
|
|
56 |
statements = getNode().selectNodes(
|
|
57 |
"//scriptdef[@name='" + macroName + "']/element | //macrodef[@name='" + macroName + "']/element");
|
|
58 |
for (Node statement : statements) {
|
588
|
59 |
macroElements = " <" + statement.valueOf("@name") + "/>\n" + macroElements;
|
587
|
60 |
}
|
|
61 |
|
|
62 |
if (macroElements.equals("")) {
|
588
|
63 |
return "<hlm:" + macroName + " " + usage + "/>";
|
587
|
64 |
}
|
|
65 |
else {
|
588
|
66 |
return "<hlm:" + macroName + " " + usage + ">\n" + macroElements + " </hlm:" + macroName + ">";
|
587
|
67 |
}
|
|
68 |
}
|
|
69 |
}
|