/** @file\r
-This file is to define nested element which is meant for specifying tool arguments\r
+This file is used to nest elements which is meant for tool's argument\r
\r
Copyright (c) 2006, Intel Corporation\r
All rights reserved. This program and the accompanying materials\r
package org.tianocore.framework.tasks;\r
\r
/**\r
- Class ToolArg is just used to specify arguments for genffsfile tool\r
+ ToolArg class is defined to represent the argument of a tool. The argument \r
+ includes the prefix (e.g. -I, -o) and the value.\r
**/\r
-public class ToolArg {\r
+public class ToolArg extends NestElement {\r
///\r
- /// keep the argument string\r
- ///\r
- private String line = "";\r
+ /// A constant which is used to represent an empty argument\r
+ /// \r
+ public final static ToolArg EMPTY_ARG = new ToolArg();\r
\r
- /**\r
- Get method of ANT task/datatype for attribute "line"\r
+ //\r
+ // Keep track the prefix of this argument\r
+ // \r
+ private String prefix = "";\r
\r
- @returns The argument string\r
+ /**\r
+ Default constructor\r
**/\r
- public String getLine() {\r
- return line;\r
+ public ToolArg() {\r
}\r
\r
/**\r
- Set method of ANT task/datatype for attribute "line"\r
+ Constructor which will initialize the prefix of this argument\r
\r
- @param line The argument string\r
- **/\r
+ @param prefix The string of prefix\r
+ */\r
+ public ToolArg(String prefix) {\r
+ this.prefix = prefix;\r
+ }\r
+\r
+ /**\r
+ Constructor which will initialize both the prefix and value of this argument\r
+ \r
+ @param prefix The prefix of this argument\r
+ @param value The value of this argument\r
+ */\r
+ public ToolArg(String prefix, String value) {\r
+ setArg(prefix, value);\r
+ }\r
+\r
+ /**\r
+ Set the prefix and value of this argument\r
+\r
+ @param prefix The prefix of this argument\r
+ @param value The value of this argument \r
+ */\r
+ public void setArg(String prefix, String value) {\r
+ this.prefix = prefix;\r
+ super.setName(value);\r
+ }\r
+\r
+ /**\r
+ Set the prefix of this argument\r
+\r
+ @param prefix The prefix of this argument\r
+ */\r
+ public void setPrefix(String prefix) {\r
+ this.prefix = prefix;\r
+ }\r
+\r
+ /**\r
+ Get the prefix of this argument\r
+\r
+ @return String The prefix of this argument\r
+ */\r
+ public String getPrefix() {\r
+ return this.prefix.trim();\r
+ }\r
+\r
+ /**\r
+ Set the value of this argument\r
+\r
+ @param value The value of this argument\r
+ */\r
+ public void setValue(String value) {\r
+ super.setName(value);\r
+ }\r
+\r
+ /**\r
+ Add a value for this argument\r
+\r
+ @param value The value of this argument\r
+ */\r
+ public void insValue(String value) {\r
+ super.insName(value);\r
+ }\r
+\r
+ /**\r
+ Get the value list of this argument, separated by space\r
+\r
+ @return String The value list\r
+ */\r
+ public String getValue() {\r
+ return super.toString(" ").trim();\r
+ }\r
+\r
+ /**\r
+ Set the argument as a whole\r
+\r
+ @param line The argument string line\r
+ */\r
public void setLine(String line) {\r
- this.line = line;\r
- } \r
-}
\ No newline at end of file
+ //\r
+ // Since the prefix is in the "line", we don't need another prefix.\r
+ // \r
+ this.prefix = " ";\r
+ super.setName(line);\r
+ }\r
+\r
+ /**\r
+ Get the argument line\r
+\r
+ @return String The argument string line\r
+ */\r
+ public String getLine() {\r
+ return this.toString();\r
+ }\r
+\r
+ /**\r
+ Compose a complete argument string.\r
+\r
+ @return String The complete argument\r
+ */\r
+ public String toString() {\r
+ return super.toString(prefix);\r
+ }\r
+}\r