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.util.ArrayList;
|
|
23 |
import java.util.List;
|
|
24 |
|
|
25 |
import org.dom4j.Element;
|
|
26 |
|
|
27 |
/**
|
|
28 |
* Abstract meta object that represents the root objects found in Ant files.
|
|
29 |
*/
|
|
30 |
public class RootAntObjectMeta extends AntObjectMeta {
|
|
31 |
static final String DEFAULT_PACKAGE = "(default)";
|
|
32 |
|
|
33 |
private AntFile antFile;
|
628
|
34 |
private String filepath;
|
587
|
35 |
private String scopeFilter;
|
|
36 |
|
|
37 |
public RootAntObjectMeta(AntFile antFile, Element node) throws IOException {
|
|
38 |
super(null, node);
|
|
39 |
this.antFile = antFile;
|
628
|
40 |
this.filepath = antFile.getFile().getCanonicalPath();
|
587
|
41 |
}
|
|
42 |
|
|
43 |
public String getPackage() {
|
|
44 |
return getComment().getTagValue("package", DEFAULT_PACKAGE);
|
|
45 |
}
|
|
46 |
|
|
47 |
public File getFile() {
|
|
48 |
return antFile.getFile();
|
|
49 |
}
|
|
50 |
|
|
51 |
public AntFile getAntFile() {
|
|
52 |
return antFile;
|
|
53 |
}
|
628
|
54 |
|
|
55 |
/**
|
|
56 |
* Returns the location path of the object.
|
|
57 |
*
|
|
58 |
* @return Location path string.
|
|
59 |
*/
|
|
60 |
public String getFilePath() {
|
|
61 |
return filepath;
|
|
62 |
}
|
587
|
63 |
|
|
64 |
public void setScopeFilter(String scopeFilter) {
|
|
65 |
this.scopeFilter = scopeFilter;
|
|
66 |
}
|
|
67 |
|
|
68 |
public String getScopeFilter() {
|
|
69 |
return scopeFilter;
|
|
70 |
}
|
|
71 |
|
|
72 |
public RootAntObjectMeta getRootMeta() {
|
|
73 |
return this;
|
|
74 |
}
|
|
75 |
|
|
76 |
@SuppressWarnings("unchecked")
|
|
77 |
public List<MacroMeta> getMacros() throws IOException {
|
|
78 |
ArrayList<MacroMeta> objects = new ArrayList<MacroMeta>();
|
|
79 |
List<Element> nodes = getNode().selectNodes("//macrodef | //scriptdef");
|
|
80 |
for (Element node : nodes) {
|
|
81 |
MacroMeta macroMeta = new MacroMeta(this, node);
|
|
82 |
macroMeta.setRuntimeProject(getRuntimeProject());
|
|
83 |
if (macroMeta.matchesScope(scopeFilter)) {
|
|
84 |
objects.add(macroMeta);
|
|
85 |
}
|
|
86 |
}
|
|
87 |
return objects;
|
|
88 |
}
|
|
89 |
}
|
628
|
90 |
|
|
91 |
|