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