buildframework/helium/sf/java/environment/src/com/nokia/helium/environment/ant/types/EnvData.java
changeset 628 7c4a911dc066
equal deleted inserted replaced
588:c7c26511138f 628:7c4a911dc066
       
     1 /*
       
     2  * Copyright (c) 2010 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.environment.ant.types;
       
    19 
       
    20 import java.io.File;
       
    21 import java.io.IOException;
       
    22 import java.util.ArrayList;
       
    23 import java.util.Iterator;
       
    24 import java.util.List;
       
    25 
       
    26 import org.apache.tools.ant.types.DataType;
       
    27 import org.apache.tools.ant.types.DirSet;
       
    28 
       
    29 /**
       
    30  * Environmental data configuration for the <environment> task.
       
    31  * 
       
    32  * @ant.task name="envdata" category="Environment"
       
    33  */
       
    34 public class EnvData extends DataType {
       
    35 
       
    36     private List<ExecutableInfo> executables = new ArrayList<ExecutableInfo>();
       
    37     private List<DirSet> dirsets = new ArrayList<DirSet>();
       
    38 
       
    39     public void add(ExecutableInfo executable) {
       
    40         if (isReference()) {
       
    41             throw noChildrenAllowed();
       
    42         }
       
    43         executables.add(executable);
       
    44     }
       
    45 
       
    46     public void add(DirSet dirset) {
       
    47         if (isReference()) {
       
    48             throw noChildrenAllowed();
       
    49         }
       
    50         dirsets.add(dirset);
       
    51     }
       
    52 
       
    53     public void getExecutableDefs(List<ExecutableInfo> executableDefs) throws IOException {
       
    54         if (isReference()) {
       
    55             EnvData envDataSource = (EnvData) getCheckedRef();
       
    56             envDataSource.getExecutableDefs(executableDefs);
       
    57         }
       
    58         else {
       
    59             for (Iterator<ExecutableInfo> iterator = this.executables.iterator(); iterator.hasNext();) {
       
    60                 ExecutableInfo executableDef = (ExecutableInfo) iterator.next();
       
    61                 if (!executableDefs.contains(executableDef)) {
       
    62                     executableDefs.add(executableDef);
       
    63                 }
       
    64 
       
    65             }
       
    66         }
       
    67     }
       
    68     
       
    69     @SuppressWarnings("unchecked")
       
    70     public void getDirectories(List<File> directories) throws IOException {
       
    71         if (isReference()) {
       
    72             EnvData envDataSource = (EnvData) getCheckedRef();
       
    73             envDataSource.getDirectories(directories);
       
    74         }
       
    75         else {
       
    76             for (Iterator<DirSet> iterator = this.dirsets.iterator(); iterator.hasNext();) {
       
    77                 DirSet dirset = (DirSet) iterator.next();
       
    78                 Iterator dirsetIterator = dirset.iterator();
       
    79                 while (dirsetIterator.hasNext()) {
       
    80                     File file = (File) dirsetIterator.next();
       
    81                     directories.add(file);
       
    82                 }
       
    83             }
       
    84         }
       
    85     }
       
    86 }
       
    87 
       
    88 
       
    89