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