2 This file is used to define class which represents dependency file in ANT task
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 package org
.tianocore
.build
.global
;
16 import org
.apache
.tools
.ant
.types
.DataType
;
17 import org
.apache
.tools
.ant
.types
.Path
;
20 import java
.io
.FileReader
;
21 import java
.io
.IOException
;
22 import java
.io
.LineNumberReader
;
23 import java
.util
.ArrayList
;
24 import java
.util
.List
;
25 import java
.util
.regex
.Matcher
;
26 import java
.util
.regex
.Pattern
;
29 DpFile is a ANT DataType which can be used to specify dependency files from
30 a file list file, from file list string separated by space, comma or semi-comma,
31 or from file name with absolute path
33 public class DpFile
extends DataType
{
35 /// keep the list of files path
37 private List
<String
> nameList
= new ArrayList
<String
>();
40 Empty constructor just in case
46 Empty execute method of ANT task, just in case
48 public void execute() {
52 Standard set method of ANT task/datatype, for ListFile attribute. It simply
53 fetch one file path a line from specified list file, and put them in nameList
55 @param fileListFile file which contains a file list, one file a line,
58 public void setListFile(String fileListFile
) {
59 File file
= new File(fileListFile
);
65 FileReader fileReader
= new FileReader(file
);
66 LineNumberReader lineReader
= new LineNumberReader(fileReader
);
68 String filePath
= null;
69 while ((filePath
= lineReader
.readLine()) != null) {
70 filePath
= filePath
.trim();
71 if (filePath
.length() == 0) {
74 this.nameList
.add(filePath
);
79 } catch (IOException e
) {
80 System
.out
.println (e
.getMessage());
85 Standard set method of ANT task/datatype, for List attribute.
87 @param fileList string with file pathes separated by space, comma,
90 public void setList(String fileList
) {
92 // space, comma or semi-comma separated files list
94 Pattern pattern
= Pattern
.compile("([^ ,;\n\r]++)[ ,;\n\r]*+");
95 Matcher matcher
= pattern
.matcher(fileList
);
97 while (matcher
.find()) {
99 // keep each file name before " ,;\n\r"
101 String filePath
= fileList
.substring(matcher
.start(1), matcher
.end(1)).trim();
102 if (filePath
.length() == 0) {
105 nameList
.add(Path
.translateFile(filePath
));
111 Standard set method of ANT task/datatype, for Name attribute.
113 @param fileName string of a file full path
115 public void setName(String fileName
) {
116 this.nameList
.add(fileName
);
120 Fetch the file name list.
122 @returns A string list which contains file names specified to check dependnecy
124 public List
<String
> getList() {
125 return this.nameList
;