]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /** @file\r |
93f5dd0a | 2 | This file is used to nest elements which is meant for tool's argument\r |
878ddf1f | 3 | \r |
4 | Copyright (c) 2006, Intel Corporation\r | |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | package org.tianocore.framework.tasks;\r | |
15 | \r | |
16 | /**\r | |
93f5dd0a | 17 | ToolArg class is defined to represent the argument of a tool. The argument \r |
18 | includes the prefix (e.g. -I, -o) and the value.\r | |
878ddf1f | 19 | **/\r |
93f5dd0a | 20 | public class ToolArg extends NestElement {\r |
878ddf1f | 21 | ///\r |
93f5dd0a | 22 | /// A constant which is used to represent an empty argument\r |
23 | /// \r | |
24 | public final static ToolArg EMPTY_ARG = new ToolArg();\r | |
878ddf1f | 25 | \r |
93f5dd0a | 26 | //\r |
27 | // Keep track the prefix of this argument\r | |
28 | // \r | |
29 | private String prefix = "";\r | |
878ddf1f | 30 | \r |
93f5dd0a | 31 | /**\r |
32 | Default constructor\r | |
878ddf1f | 33 | **/\r |
93f5dd0a | 34 | public ToolArg() {\r |
878ddf1f | 35 | }\r |
36 | \r | |
37 | /**\r | |
93f5dd0a | 38 | Constructor which will initialize the prefix of this argument\r |
878ddf1f | 39 | \r |
93f5dd0a | 40 | @param prefix The string of prefix\r |
41 | */\r | |
42 | public ToolArg(String prefix) {\r | |
43 | this.prefix = prefix;\r | |
44 | }\r | |
45 | \r | |
46 | /**\r | |
47 | Constructor which will initialize both the prefix and value of this argument\r | |
48 | \r | |
49 | @param prefix The prefix of this argument\r | |
50 | @param value The value of this argument\r | |
51 | */\r | |
52 | public ToolArg(String prefix, String value) {\r | |
53 | setArg(prefix, value);\r | |
54 | }\r | |
55 | \r | |
56 | /**\r | |
57 | Set the prefix and value of this argument\r | |
58 | \r | |
59 | @param prefix The prefix of this argument\r | |
60 | @param value The value of this argument \r | |
61 | */\r | |
62 | public void setArg(String prefix, String value) {\r | |
63 | this.prefix = prefix;\r | |
64 | super.setName(value);\r | |
65 | }\r | |
66 | \r | |
67 | /**\r | |
68 | Set the prefix of this argument\r | |
69 | \r | |
70 | @param prefix The prefix of this argument\r | |
71 | */\r | |
72 | public void setPrefix(String prefix) {\r | |
73 | this.prefix = prefix;\r | |
74 | }\r | |
75 | \r | |
76 | /**\r | |
77 | Get the prefix of this argument\r | |
78 | \r | |
79 | @return String The prefix of this argument\r | |
80 | */\r | |
81 | public String getPrefix() {\r | |
82 | return this.prefix.trim();\r | |
83 | }\r | |
84 | \r | |
85 | /**\r | |
86 | Set the value of this argument\r | |
87 | \r | |
88 | @param value The value of this argument\r | |
89 | */\r | |
90 | public void setValue(String value) {\r | |
91 | super.setName(value);\r | |
92 | }\r | |
93 | \r | |
94 | /**\r | |
95 | Add a value for this argument\r | |
96 | \r | |
97 | @param value The value of this argument\r | |
98 | */\r | |
99 | public void insValue(String value) {\r | |
100 | super.insName(value);\r | |
101 | }\r | |
102 | \r | |
103 | /**\r | |
104 | Get the value list of this argument, separated by space\r | |
105 | \r | |
106 | @return String The value list\r | |
107 | */\r | |
108 | public String getValue() {\r | |
109 | return super.toString(" ").trim();\r | |
110 | }\r | |
111 | \r | |
112 | /**\r | |
113 | Set the argument as a whole\r | |
114 | \r | |
115 | @param line The argument string line\r | |
116 | */\r | |
878ddf1f | 117 | public void setLine(String line) {\r |
93f5dd0a | 118 | //\r |
119 | // Since the prefix is in the "line", we don't need another prefix.\r | |
120 | // \r | |
121 | this.prefix = " ";\r | |
122 | super.setName(line);\r | |
123 | }\r | |
124 | \r | |
125 | /**\r | |
126 | Get the argument line\r | |
127 | \r | |
128 | @return String The argument string line\r | |
129 | */\r | |
130 | public String getLine() {\r | |
131 | return this.toString();\r | |
132 | }\r | |
133 | \r | |
134 | /**\r | |
135 | Compose a complete argument string.\r | |
136 | \r | |
137 | @return String The complete argument\r | |
138 | */\r | |
139 | public String toString() {\r | |
140 | return super.toString(prefix);\r | |
141 | }\r | |
d946661a | 142 | \r |
143 | /**\r | |
144 | Check if the argument is empty or not\r | |
145 | \r | |
146 | @return boolean\r | |
147 | **/\r | |
148 | public boolean isEmpty() {\r | |
149 | return (prefix.length() == 0) && (nameList.isEmpty());\r | |
150 | }\r | |
93f5dd0a | 151 | }\r |