]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/DistributerDef.java
Restructuring for better separation of Tool packages.
[mirror_edk2.git] / Tools / Java / Source / Cpptasks / net / sf / antcontrib / cpptasks / DistributerDef.java
1 /*
2 *
3 * Copyright 2004 The Ant-Contrib project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package net.sf.antcontrib.cpptasks;
18
19
20 import org.apache.tools.ant.types.DataType;
21 import org.apache.tools.ant.types.Reference;
22 import java.util.Vector;
23
24 /**
25 * Distributed build information (Non-functional prototype).
26 *
27 */
28 public final class DistributerDef
29 extends DataType {
30 /**
31 * if property.
32 */
33 private String ifCond;
34
35 /**
36 * unless property.
37 */
38 private String unlessCond;
39
40 /**
41 * hosts.
42 *
43 */
44 private String hosts;
45
46 /**
47 * Protocol.
48 *
49 */
50 private DistributerProtocolEnum protocol;
51
52 /**
53 * Not sure what this is.
54 */
55 private int tcpCork;
56
57 /**
58 * user name.
59 */
60 private String user;
61
62 /**
63 * local to remote file name maps.
64 */
65 private final Vector maps = new Vector();
66
67 /**
68 * Constructor.
69 *
70 */
71 public DistributerDef() {
72 }
73
74 /**
75 * Required by documentation generator.
76 */
77 public void execute() {
78 throw new org.apache.tools.ant.BuildException(
79 "Not an actual task, but looks like one for documentation purposes");
80 }
81
82 /**
83 * Returns true if the if and unless conditions (if any) are
84 * satisfied.
85 * @return true if definition is active.
86 */
87 public boolean isActive() {
88 return CUtil.isActive(getProject(), ifCond, unlessCond);
89 }
90
91 /**
92 * Sets an id that can be used to reference this element.
93 *
94 * @param id
95 * id
96 */
97 public void setId(final String id) {
98 //
99 // this is actually accomplished by a different
100 // mechanism, but we can document it
101 //
102 }
103
104 /**
105 * Sets the property name for the 'if' condition.
106 *
107 * The define will be ignored unless the property is defined.
108 *
109 * The value of the property is insignificant, but values that would imply
110 * misinterpretation ("false", "no") will throw an exception when
111 * evaluated.
112 *
113 * @param propName
114 * property name
115 */
116 public void setIf(final String propName) {
117 ifCond = propName;
118 }
119
120 /**
121 * Specifies that this element should behave as if the content of the
122 * element with the matching id attribute was inserted at this location. If
123 * specified, no other attributes should be specified.
124 * @param r reference name
125 */
126 public void setRefid(final Reference r) {
127 super.setRefid(r);
128 }
129
130 /**
131 * Set the property name for the 'unless' condition.
132 *
133 * If named property is set, the define will be ignored.
134 *
135 * The value of the property is insignificant, but values that would imply
136 * misinterpretation ("false", "no") of the behavior will throw an
137 * exception when evaluated.
138 *
139 * @param propName
140 * name of property
141 */
142 public void setUnless(final String propName) {
143 unlessCond = propName;
144 }
145
146 /**
147 * Gets hosts.
148 * @return hosts, may be null.
149 *
150 */
151 public String getHosts() {
152 if (isReference()) {
153 DistributerDef refDistributer = (DistributerDef)
154 getCheckedRef(DistributerDef.class,
155 "DistributerDef");
156 return refDistributer.getHosts();
157 }
158 return hosts;
159 }
160
161 /**
162 * Gets tcp cork.
163 * @return TCP_CORK value.
164 *
165 */
166 public int getTcpcork() {
167 if (isReference()) {
168 DistributerDef refDistributer = (DistributerDef)
169 getCheckedRef(DistributerDef.class,
170 "DistributerDef");
171 return refDistributer.getTcpcork();
172 }
173 return tcpCork;
174 }
175
176 /**
177 * Gets protocol.
178 * @return protocol, may be null.
179 *
180 */
181 public DistributerProtocolEnum getProtocol() {
182 if (isReference()) {
183 DistributerDef refDistributer = (DistributerDef)
184 getCheckedRef(DistributerDef.class,
185 "DistributerDef");
186 return refDistributer.getProtocol();
187 }
188 return protocol;
189 }
190
191 /**
192 * Sets hosts.
193 * @param value new value
194 */
195 public void setHosts(final String value) {
196 if (isReference()) {
197 throw tooManyAttributes();
198 }
199 hosts = value;
200 }
201
202 /**
203 * Sets TCP_CORK value.
204 * @param value new value
205 */
206 public void setTcpcork(final int value) {
207 if (isReference()) {
208 throw tooManyAttributes();
209 }
210 tcpCork = value;
211 }
212
213 /**
214 * Sets protocol.
215 * @param value new value
216 */
217 public void setProtocol(final DistributerProtocolEnum value) {
218 if (isReference()) {
219 throw tooManyAttributes();
220 }
221 protocol = value;
222 }
223
224 /**
225 * Local to remote filename maps.
226 * @return new map
227 */
228 public DistributerMap createMap() {
229 DistributerMap map = new DistributerMap();
230 map.setProject(getProject());
231 maps.addElement(map);
232 return map;
233 }
234
235 /**
236 * Sets remote user name.
237 * @param value user name
238 */
239 public void setUser(final String value) {
240 user = value;
241 }
242
243 }