]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/NestElement.java
1) Changed ToolArg class to abstract generic arguments of a tool
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / NestElement.java
index a402392349a3b4a1c2a77f18ce5ef91b6ce80f6b..be1d88aa35a5c131dbb0d1b0ccb723b1a44fbc05 100644 (file)
@@ -34,6 +34,15 @@ public class NestElement extends DataType {
     //\r
     private List<String> nameList = new ArrayList<String>();\r
 \r
+    /**\r
+       Insert content in the newElement into this NestElement\r
+\r
+       @param newElement    The new NestElement\r
+     **/\r
+    public void insert(NestElement newElement) {\r
+        this.nameList.addAll(newElement.getNameList());\r
+    }\r
+\r
     /**\r
        Handle "name" attribute. No delimiter and special treatment are assumed.\r
 \r
@@ -41,7 +50,14 @@ public class NestElement extends DataType {
      **/\r
     public void setName(String name) {\r
         if (name.length() > 0) {\r
-            nameList.add(name);\r
+            this.nameList.clear();\r
+            this.nameList.add(name);\r
+        }\r
+    }\r
+\r
+    public void insName(String name) {\r
+        if (name.length() > 0) {\r
+            this.nameList.add(name);\r
         }\r
     }\r
 \r
@@ -56,6 +72,7 @@ public class NestElement extends DataType {
             return;\r
         }\r
 \r
+        this.nameList.clear();\r
         StringTokenizer tokens = new StringTokenizer(nameList, " \t,;", false);\r
         while (tokens.hasMoreTokens()) {\r
             String name = tokens.nextToken().trim();\r
@@ -91,6 +108,7 @@ public class NestElement extends DataType {
             //\r
             // Read line by line\r
             // \r
+            nameList.clear();\r
             while((str = in.readLine()) != null){\r
                 str = str.trim();\r
                 if (str.length() == 0){\r
@@ -98,7 +116,7 @@ public class NestElement extends DataType {
                 }\r
 \r
                 //getProject().replaceProperties(str);\r
-                nameList.add(str);\r
+                this.nameList.add(str);\r
             }\r
         } catch (Exception e){\r
             throw new BuildException(e.getMessage());            \r
@@ -128,6 +146,15 @@ public class NestElement extends DataType {
         setPath(file);\r
     }\r
 \r
+    /**\r
+       Add a file or file list into the file list\r
+\r
+       @param file  The path of a file\r
+     **/\r
+    public void insFile(String file) {\r
+        insPath(file);\r
+    }\r
+\r
     /**\r
        Handle "path" attribute. The value of "path" may contain compound path\r
        separator (/ or \) which should be cleaned up. Because the "path" string\r
@@ -139,6 +166,16 @@ public class NestElement extends DataType {
        @param path  String value of a file system path\r
      **/\r
     public void setPath(String path) {\r
+        this.nameList.clear();\r
+        insPath(path);\r
+    }\r
+\r
+    /**\r
+       Add a path or path list into the path list\r
+\r
+       @param path  The path string\r
+     **/\r
+    public void insPath(String path) {\r
         if (path.length() == 0) {\r
             return;\r
         }\r
@@ -184,6 +221,7 @@ public class NestElement extends DataType {
             //\r
             // Read the file line by line, skipping empty ones\r
             // \r
+            nameList.clear();\r
             while((path = in.readLine()) != null){\r
                 path = path.trim();\r
                 if (path.length() == 0){\r
@@ -254,6 +292,47 @@ public class NestElement extends DataType {
         return string.toString();\r
     }\r
 \r
+    /**\r
+       Compose and return the name/path string concatenated by space and\r
+       with only one "prefix".\r
+\r
+       @param prefix    The prefix at the beginning of the string\r
+       \r
+       @return String   The string with one prefix at the beginning\r
+     **/\r
+    public String toStringWithSinglepPrefix(String prefix) {\r
+        return prefix + toString(" ");\r
+    }\r
+\r
+    /**\r
+       Compose a string list with file names only, separated by spcified string\r
+\r
+       @param separator     The separator string\r
+       \r
+       @return String       The file list\r
+     **/\r
+    public String toFileList(String separator) {\r
+        StringBuffer string = new StringBuffer(1024);\r
+        int length = nameList.size();\r
+\r
+        for (int i = 0; i < length; ++i) {\r
+            File file = new File(nameList.get(i));\r
+            string.append(file.getName());\r
+            string.append(separator);\r
+        }\r
+\r
+        return string.toString();\r
+    }\r
+\r
+    /**\r
+       Compose a string list with file names only, separated by space\r
+\r
+       @return String   The list string\r
+     **/\r
+    public String toFileList() {\r
+        return toFileList(" ");\r
+    }\r
+\r
     //\r
     // Remove any duplicated path separator or inconsistent path separator\r
     //\r