-/** @file\r
- FileParser class.\r
-\r
- FileParser class is to parse file which contains the list of file name and \r
- add those files to list.\r
- \r
- \r
- Copyright (c) 2006, Intel Corporation\r
- All rights reserved. This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
- \r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
- **/\r
-package org.tianocore.framework.tasks;\r
-import java.io.*;\r
-import java.util.List;\r
-\r
-import org.apache.tools.ant.BuildException;\r
-import org.apache.tools.ant.Project;\r
-\r
-/**\r
- FileParser class.\r
-\r
- FileParser class is to parse file which contains the list of file name and \r
- add those files to list.\r
-**/\r
-public class FileParser {\r
- /**\r
- loadFile\r
- \r
- This function is to add files to array from input file which contains the \r
- files list.\r
- @param project The current project.\r
- @param list File array.\r
- @param file File which contains the file list.\r
- @param tag Target of architecture.\r
- @throws BuildException\r
- **/\r
- public static synchronized void loadFile(Project project, List<Object> list, File file, String tag) throws BuildException{\r
- FileReader fileReader;\r
- BufferedReader in;\r
- String str;\r
- \r
- if (!file.exists()) {\r
- throw new BuildException("The file, " + file + " does not exist!"); \r
- } \r
- try {\r
- fileReader = new FileReader(file);\r
- in = new BufferedReader(fileReader);\r
- while((str=in.readLine())!= null){\r
- if (str.trim()==""){\r
- continue;\r
- }\r
- str = project.replaceProperties(str);\r
- if (str.trim().substring(0,2).equalsIgnoreCase(tag)) {\r
- list.add(str.trim());\r
- } else {\r
- list.add(tag + " " + str.trim());\r
- }\r
- \r
- }\r
- } catch (Exception e){\r
- System.out.println(e.getMessage());\r
- \r
- }\r
- }\r
- \r
-}\r