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.io.File;
|
|
21 |
import java.io.IOException;
|
|
22 |
import java.text.BreakIterator;
|
|
23 |
import java.util.ArrayList;
|
628
|
24 |
import java.util.Iterator;
|
587
|
25 |
import java.util.List;
|
|
26 |
|
|
27 |
import org.dom4j.Comment;
|
628
|
28 |
import org.dom4j.Document;
|
|
29 |
import org.dom4j.DocumentHelper;
|
587
|
30 |
import org.dom4j.Element;
|
|
31 |
import org.dom4j.Node;
|
628
|
32 |
import org.dom4j.XPath;
|
587
|
33 |
|
|
34 |
/**
|
|
35 |
* Meta object for an Ant project.
|
|
36 |
*/
|
|
37 |
public class ProjectMeta extends RootAntObjectMeta {
|
|
38 |
private static final String DOC_COMMENT_MARKER = "*";
|
|
39 |
|
|
40 |
private String description = "";
|
|
41 |
|
628
|
42 |
public ProjectMeta(AntFile antFile, Element node) throws IOException {
|
587
|
43 |
super(antFile, node);
|
|
44 |
|
|
45 |
// Only parse a project comment if it is marked
|
|
46 |
if (!getComment().isMarkedComment()) {
|
|
47 |
setComment(getEmptyComment());
|
|
48 |
}
|
|
49 |
|
|
50 |
Element descriptionNode = ((Element) getNode()).element("description");
|
|
51 |
if (descriptionNode != null) {
|
|
52 |
description = AntComment.getCleanedDocNodeText(descriptionNode);
|
|
53 |
}
|
|
54 |
}
|
|
55 |
|
|
56 |
public File getFile() {
|
|
57 |
return this.getAntFile().getFile();
|
|
58 |
}
|
|
59 |
|
|
60 |
public String getDefault() {
|
|
61 |
return getAttr("default");
|
|
62 |
}
|
|
63 |
|
|
64 |
public String getDescription() {
|
|
65 |
return description;
|
|
66 |
}
|
|
67 |
|
|
68 |
public String getPackage() {
|
|
69 |
return getComment().getTagValue("package", DEFAULT_PACKAGE);
|
|
70 |
}
|
|
71 |
|
|
72 |
public String getSummary() {
|
|
73 |
String text = getDescription();
|
|
74 |
if (text.length() == 0) {
|
|
75 |
text = getDocumentation();
|
|
76 |
}
|
|
77 |
BreakIterator iterator = BreakIterator.getSentenceInstance();
|
|
78 |
iterator.setText(text);
|
|
79 |
String summary = "";
|
|
80 |
if (iterator.next() > 0) {
|
|
81 |
summary = text.substring(0, iterator.current()).trim();
|
|
82 |
}
|
|
83 |
return summary;
|
|
84 |
}
|
|
85 |
|
|
86 |
@SuppressWarnings("unchecked")
|
628
|
87 |
public List<TargetMeta> getTargets() {
|
587
|
88 |
ArrayList<TargetMeta> objects = new ArrayList<TargetMeta>();
|
|
89 |
List<Node> nodes = getNode().selectNodes("target");
|
|
90 |
for (Node targetNode : nodes) {
|
|
91 |
TargetMeta targetMeta = new TargetMeta(this, targetNode);
|
|
92 |
targetMeta.setRuntimeProject(getRuntimeProject());
|
|
93 |
if (targetMeta.matchesScope(getScopeFilter())) {
|
|
94 |
objects.add(targetMeta);
|
|
95 |
}
|
|
96 |
}
|
|
97 |
return objects;
|
|
98 |
}
|
|
99 |
|
|
100 |
@SuppressWarnings("unchecked")
|
628
|
101 |
public List<PropertyMeta> getProperties() {
|
587
|
102 |
List<PropertyMeta> properties = new ArrayList<PropertyMeta>();
|
588
|
103 |
List<Node> propertyNodes = getNode().selectNodes("//property[string-length(@name)>0]");
|
587
|
104 |
for (Node propNode : propertyNodes) {
|
|
105 |
PropertyMeta propertyMeta = new PropertyMeta(this, propNode);
|
|
106 |
propertyMeta.setRuntimeProject(getRuntimeProject());
|
|
107 |
if (propertyMeta.matchesScope(getScopeFilter())) {
|
|
108 |
properties.add(propertyMeta);
|
|
109 |
}
|
|
110 |
}
|
|
111 |
return properties;
|
|
112 |
}
|
|
113 |
|
|
114 |
@SuppressWarnings("unchecked")
|
628
|
115 |
public List<MacroMeta> getMacros() {
|
587
|
116 |
ArrayList<MacroMeta> objects = new ArrayList<MacroMeta>();
|
|
117 |
List<Element> nodes = getNode().selectNodes("//macrodef | //scriptdef");
|
|
118 |
for (Element node : nodes) {
|
|
119 |
MacroMeta macroMeta = new MacroMeta(this, node);
|
|
120 |
macroMeta.setRuntimeProject(getRuntimeProject());
|
|
121 |
if (macroMeta.matchesScope(getScopeFilter())) {
|
|
122 |
objects.add(macroMeta);
|
|
123 |
}
|
|
124 |
}
|
|
125 |
return objects;
|
|
126 |
}
|
|
127 |
|
|
128 |
@SuppressWarnings("unchecked")
|
|
129 |
public List<String> getProjectDependencies() {
|
|
130 |
ArrayList<String> objects = new ArrayList<String>();
|
|
131 |
List<Element> importNodes = getNode().selectNodes("//import");
|
|
132 |
for (Element node : importNodes) {
|
|
133 |
objects.add(node.attributeValue("file"));
|
|
134 |
}
|
|
135 |
return objects;
|
|
136 |
}
|
|
137 |
|
|
138 |
@SuppressWarnings("unchecked")
|
|
139 |
public List<String> getLibraryDependencies() {
|
|
140 |
ArrayList<String> objects = new ArrayList<String>();
|
|
141 |
List<Element> nodes = getNode().selectNodes("//typedef");
|
|
142 |
for (Element node : nodes) {
|
|
143 |
if (node.attributeValue("file") != null) {
|
|
144 |
objects.add(node.attributeValue("file"));
|
|
145 |
}
|
|
146 |
else if (node.attributeValue("resource") != null) {
|
|
147 |
objects.add(node.attributeValue("resource"));
|
|
148 |
}
|
|
149 |
}
|
|
150 |
return objects;
|
|
151 |
}
|
|
152 |
|
|
153 |
@SuppressWarnings("unchecked")
|
628
|
154 |
public List<PropertyCommentMeta> getPropertyCommentBlocks() {
|
587
|
155 |
ArrayList<PropertyCommentMeta> objects = new ArrayList<PropertyCommentMeta>();
|
|
156 |
List<Node> nodes = getNode().selectNodes("//comment()");
|
|
157 |
for (Node node : nodes) {
|
|
158 |
String text = node.getText().trim();
|
|
159 |
if (text.startsWith(DOC_COMMENT_MARKER + " @property")) {
|
|
160 |
PropertyCommentMeta propertyCommentMeta = new PropertyCommentMeta(this, (Comment) node);
|
|
161 |
propertyCommentMeta.setRuntimeProject(getRuntimeProject());
|
628
|
162 |
if (propertyCommentMeta.matchesScope(getScopeFilter())) {
|
|
163 |
objects.add(propertyCommentMeta);
|
|
164 |
}
|
587
|
165 |
}
|
|
166 |
}
|
|
167 |
return objects;
|
|
168 |
}
|
628
|
169 |
|
|
170 |
@SuppressWarnings("unchecked")
|
|
171 |
public void getConfigSignals(String targetName, List<String> signals) {
|
|
172 |
XPath xpath = DocumentHelper.createXPath("//hlm:signalListenerConfig[@target='"
|
|
173 |
+ targetName + "']");
|
|
174 |
xpath.setNamespaceURIs(Database.NAMESPACE_MAP);
|
|
175 |
List<Node> signalNodes = xpath.selectNodes(getNode());
|
|
176 |
for (Iterator<Node> iterator = signalNodes.iterator(); iterator.hasNext();) {
|
|
177 |
Element propertyNode = (Element) iterator.next();
|
|
178 |
String signalid = propertyNode.attributeValue("id");
|
|
179 |
String failbuild = findSignalFailMode(signalid, getNode().getDocument());
|
|
180 |
signals.add(signalid + "(" + failbuild + ")");
|
|
181 |
}
|
|
182 |
}
|
|
183 |
|
|
184 |
@SuppressWarnings("unchecked")
|
|
185 |
private String findSignalFailMode(String signalid, Document antDoc) {
|
|
186 |
XPath xpath2 = DocumentHelper.createXPath("//hlm:signalListenerConfig[@id='" + signalid
|
|
187 |
+ "']/signalNotifierInput/signalInput");
|
|
188 |
xpath2.setNamespaceURIs(Database.NAMESPACE_MAP);
|
|
189 |
List signalNodes3 = xpath2.selectNodes(antDoc);
|
|
190 |
|
|
191 |
for (Iterator iterator3 = signalNodes3.iterator(); iterator3.hasNext();) {
|
|
192 |
Element propertyNode3 = (Element) iterator3.next();
|
|
193 |
String signalinputid = propertyNode3.attributeValue("refid");
|
|
194 |
|
|
195 |
XPath xpath3 = DocumentHelper.createXPath("//hlm:signalInput[@id='" + signalinputid
|
|
196 |
+ "']");
|
|
197 |
xpath3.setNamespaceURIs(Database.NAMESPACE_MAP);
|
|
198 |
List signalNodes4 = xpath3.selectNodes(antDoc);
|
|
199 |
for (Iterator iterator4 = signalNodes4.iterator(); iterator4.hasNext();) {
|
|
200 |
Element propertyNode4 = (Element) iterator4.next();
|
|
201 |
return propertyNode4.attributeValue("failbuild");
|
|
202 |
}
|
|
203 |
}
|
|
204 |
return null;
|
|
205 |
}
|
587
|
206 |
}
|