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