buildframework/helium/sf/java/antdata/src/com/nokia/helium/ant/data/Database.java
author wbernard
Fri, 13 Aug 2010 14:59:05 +0300
changeset 628 7c4a911dc066
parent 587 85df38eb4012
child 645 b8d81fa19e7d
permissions -rw-r--r--
helium_11.0.0-e00f171ca185
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     1
/*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     2
 * All rights reserved.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     3
 * This component and the accompanying materials are made available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     4
 * under the terms of the License "Eclipse Public License v1.0"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     5
 * which accompanies this distribution, and is available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     6
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     7
 *
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     8
 * Initial Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     9
 * Nokia Corporation - initial contribution.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    10
 *
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    11
 * Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    12
 *
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    13
 * Description: 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    14
 *
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    15
 */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    16
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    17
package com.nokia.helium.ant.data;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    18
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    19
import java.io.File;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    20
import java.io.IOException;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    21
import java.io.Writer;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    22
import java.util.ArrayList;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    23
import java.util.Collection;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    24
import java.util.Collections;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    25
import java.util.HashMap;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    26
import java.util.Iterator;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    27
import java.util.List;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    28
import java.util.Map;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    29
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    30
import org.apache.tools.ant.Project;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    31
import org.apache.tools.ant.Target;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    32
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    33
import com.nokia.helium.freemarker.WikiMethod;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    34
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    35
import freemarker.cache.ClassTemplateLoader;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    36
import freemarker.cache.FileTemplateLoader;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    37
import freemarker.cache.MultiTemplateLoader;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    38
import freemarker.cache.TemplateLoader;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
import freemarker.template.Configuration;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    40
import freemarker.template.DefaultObjectWrapper;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    41
import freemarker.template.Template;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    42
import freemarker.template.TemplateException;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    43
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
/**
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    45
 * Reads the current ant project and a fileset and generates a xml file with a summary of targets,
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    46
 * macros and properties.
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    47
 */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    48
public class Database {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    49
    /** The default scope filter if no scope filter is defined. */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    50
    public static final String DEFAULT_SCOPE = "public";
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    51
    public static final Map<String, String> NAMESPACE_MAP;
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    52
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    53
    private Project rootProject;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    54
    private Map<String, AntFile> antfilesMap;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    55
    private Map<String, PackageMeta> packagesMap;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    56
    private String scopeFilter;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    57
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    58
    static {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    59
        Map<String, String> tempMap = new HashMap<String, String>();
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    60
        tempMap.put("hlm", "http://www.nokia.com/helium");
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    61
        NAMESPACE_MAP = Collections.unmodifiableMap(tempMap);
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    62
    }
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    63
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    64
    public Database(Project project) throws IOException {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    65
        this(project, DEFAULT_SCOPE);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    66
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    67
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    68
    @SuppressWarnings("unchecked")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    69
    public Database(Project project, String scopeFilter) throws IOException {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    70
        this.rootProject = project;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    71
        this.scopeFilter = scopeFilter;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    72
        antfilesMap = new HashMap<String, AntFile>();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    73
        packagesMap = new HashMap<String, PackageMeta>();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    74
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    75
        if (project != null) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    76
            Map<String, Target> targets = project.getTargets();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    77
            Iterator<Target> targetsIter = targets.values().iterator();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    78
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    79
            while (targetsIter.hasNext()) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    80
                Target target = targetsIter.next();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    81
                String antFilePath = new File(target.getLocation().getFileName()).getCanonicalPath();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    82
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    83
                if (!antfilesMap.containsKey(antFilePath)) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    84
                    addAntFile(antFilePath);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    85
                }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    86
            }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    87
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    88
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    89
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    90
    private void log(String string, int level) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    91
        if (rootProject != null) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    92
            rootProject.log(string, level);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    93
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    94
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    95
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    96
    public void addAntFilePaths(List<String> antFilePaths) throws IOException {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    97
        for (String antFilePath : antFilePaths) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    98
            addAntFile(antFilePath);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    99
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   100
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   101
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   102
    private void addAntFile(String antFilePath) throws IOException {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   103
        if (!antfilesMap.containsKey(antFilePath)) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   104
            log("Adding project to database: " + antFilePath, Project.MSG_DEBUG);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   105
            AntFile antfile = new AntFile(this, antFilePath, scopeFilter);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   106
            antfile.setProject(rootProject);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   107
            antfilesMap.put(antFilePath, antfile);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   108
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   109
            // See if project is part of a package
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   110
            checkPackageMembership(antfile);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   111
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   112
            // See if any antlibs are defined
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   113
            List<AntFile> antlibFiles = antfile.getAntlibs();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   114
            for (AntFile antFile2 : antlibFiles) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   115
                antfilesMap.put(antFile2.getFile().getCanonicalPath(), antFile2);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   116
                checkPackageMembership(antFile2);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   117
            }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   118
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   119
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   120
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   121
    private void checkPackageMembership(AntFile antfile) throws IOException {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   122
        RootAntObjectMeta rootObjectMeta = antfile.getRootObjectMeta();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   123
        String packageStr = rootObjectMeta.getPackage();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   124
        if (!packagesMap.containsKey(packageStr)) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   125
            PackageMeta packageMeta = new PackageMeta(packageStr);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   126
            packageMeta.setRuntimeProject(rootProject);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   127
            packagesMap.put(packageStr, packageMeta);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   128
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   129
        PackageMeta packageMeta = packagesMap.get(packageStr);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   130
        packageMeta.addObject(rootObjectMeta);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   131
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   132
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   133
    public void setScopeFilter(String scopeFilter) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   134
        if (!(scopeFilter.equals("public") || scopeFilter.equals("protected") || scopeFilter.equals("private"))) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   135
            throw new IllegalArgumentException("Invalid scope value");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   136
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   137
        this.scopeFilter = scopeFilter;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   138
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   139
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   140
    public void toXML(Writer out) throws IOException {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   141
        // Setup configuration
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   142
        Configuration cfg = new Configuration();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   143
        TemplateLoader[] loaders = null;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   144
        ClassTemplateLoader ctl = new ClassTemplateLoader(getClass(), "");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   145
        File testingDir = new File("src/com/nokia/helium/ant/data/taskdefs");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   146
        if (testingDir.exists()) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   147
            FileTemplateLoader ftl1 = new FileTemplateLoader(testingDir);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   148
            loaders = new TemplateLoader[] { ftl1, ctl };
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   149
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   150
        else {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   151
            loaders = new TemplateLoader[] { ctl };
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   152
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   153
        MultiTemplateLoader mtl = new MultiTemplateLoader(loaders);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   154
        cfg.setTemplateLoader(mtl);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   155
        cfg.setObjectWrapper(new DefaultObjectWrapper());
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   156
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   157
        // Create the data model
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   158
        List<ProjectMeta> projects = new ArrayList<ProjectMeta>();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   159
        List<AntlibMeta> antlibs = new ArrayList<AntlibMeta>();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   160
        for (AntFile antfile : antfilesMap.values()) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   161
            antfile.setScope(scopeFilter);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   162
            RootAntObjectMeta rootObject = antfile.getRootObjectMeta();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   163
            if (rootObject instanceof ProjectMeta) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   164
                projects.add((ProjectMeta) rootObject);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   165
            }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   166
            else {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   167
                antlibs.add((AntlibMeta) rootObject);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   168
            }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   169
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   170
        Map<String, Object> root = new HashMap<String, Object>();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   171
        root.put("projects", projects);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   172
        root.put("antlibs", antlibs);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   173
        root.put("packages", getPackages());
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   174
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   175
        // Add a custom wiki formatting method
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   176
        WikiMethod wikiMethod = new WikiMethod();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   177
        root.put("wiki", wikiMethod);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   178
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   179
        // Process template
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   180
        Template template = cfg.getTemplate("database.xml.ftl");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   181
        try {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   182
            template.process(root, out);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   183
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   184
        catch (TemplateException e) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   185
            e.printStackTrace();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   186
            throw new IOException(e.getMessage());
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   187
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   188
        out.flush();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   189
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   190
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   191
    public Collection<AntFile> getAntFiles() {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   192
        return antfilesMap.values();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   193
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   194
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
   195
    public List<PropertyMeta> getProperties() {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   196
        List<PropertyMeta> propertiesList = new ArrayList<PropertyMeta>();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   197
        for (AntFile antfile : antfilesMap.values()) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   198
            RootAntObjectMeta rootMeta = antfile.getRootObjectMeta();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   199
            if (rootMeta instanceof ProjectMeta) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   200
                propertiesList.addAll(((ProjectMeta) rootMeta).getProperties());
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   201
            }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   202
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   203
        return propertiesList;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   204
    }
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
   205
    
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
   206
    public List<PropertyCommentMeta> getCommentProperties() {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
   207
        List<PropertyCommentMeta> propertiesList = new ArrayList<PropertyCommentMeta>();
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
   208
        for (AntFile antfile : antfilesMap.values()) {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
   209
            RootAntObjectMeta rootMeta = antfile.getRootObjectMeta();
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
   210
            if (rootMeta instanceof ProjectMeta) {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
   211
                propertiesList.addAll(((ProjectMeta) rootMeta).getPropertyCommentBlocks());
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
   212
            }
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
   213
        }
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
   214
        return propertiesList;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
   215
    }
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   216
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   217
    public List<PackageMeta> getPackages() throws IOException {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   218
        List<PackageMeta> packages = new ArrayList<PackageMeta>();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   219
        for (PackageMeta packageMeta : packagesMap.values()) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   220
            packages.add(packageMeta);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   221
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   222
        return packages;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   223
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   224
}