buildframework/helium/sf/java/antdata/src/com/nokia/helium/ant/data/RootAntObjectMeta.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
 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     3
 * All rights reserved.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     5
 * under the terms of the License "Eclipse Public License v1.0"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     8
 *
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     9
 * Initial Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    11
 *
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    12
 * Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    13
 *
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    14
 * Description: 
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
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    18
package com.nokia.helium.ant.data;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    19
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    20
import java.io.File;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    21
import java.io.IOException;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    22
import java.util.ArrayList;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    23
import java.util.List;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    24
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    25
import org.dom4j.Element;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    26
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    27
/**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    28
 * Abstract meta object that represents the root objects found in Ant files.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    29
 */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    30
public class RootAntObjectMeta extends AntObjectMeta {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    31
    static final String DEFAULT_PACKAGE = "(default)";
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    32
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    33
    private AntFile antFile;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    34
    private String filepath;
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    35
    private String scopeFilter;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    36
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    37
    public RootAntObjectMeta(AntFile antFile, Element node) throws IOException {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    38
        super(null, node);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
        this.antFile = antFile;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    40
        this.filepath = antFile.getFile().getCanonicalPath();
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    41
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    42
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    43
    public String getPackage() {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
        return getComment().getTagValue("package", DEFAULT_PACKAGE);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    45
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    46
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    47
    public File getFile() {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    48
        return antFile.getFile();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    49
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    50
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    51
    public AntFile getAntFile() {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    52
        return antFile;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    53
    }
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    54
    
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    55
    /**
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    56
     * Returns the location path of the object.
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    57
     * 
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    58
     * @return Location path string.
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    59
     */
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    60
    public String getFilePath() {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    61
        return filepath;
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 void setScopeFilter(String scopeFilter) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    65
        this.scopeFilter = scopeFilter;
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
    public String getScopeFilter() {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    69
        return scopeFilter;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    70
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    71
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    72
    public RootAntObjectMeta getRootMeta() {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    73
        return this;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    74
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    75
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    76
    @SuppressWarnings("unchecked")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    77
    public List<MacroMeta> getMacros() throws IOException {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    78
        ArrayList<MacroMeta> objects = new ArrayList<MacroMeta>();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    79
        List<Element> nodes = getNode().selectNodes("//macrodef | //scriptdef");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    80
        for (Element node : nodes) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    81
            MacroMeta macroMeta = new MacroMeta(this, node);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    82
            macroMeta.setRuntimeProject(getRuntimeProject());
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    83
            if (macroMeta.matchesScope(scopeFilter)) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    84
                objects.add(macroMeta);
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
        return objects;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    88
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    89
}
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    90
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    91