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