Lines 29-34
Link Here
|
29 |
import java.util.Map; |
29 |
import java.util.Map; |
30 |
import java.util.Iterator; |
30 |
import java.util.Iterator; |
31 |
|
31 |
|
|
|
32 |
import org.apache.tools.ant.attribute.EnableAttribute; |
33 |
|
32 |
import org.apache.tools.ant.util.CollectionUtils; |
34 |
import org.apache.tools.ant.util.CollectionUtils; |
33 |
import org.xml.sax.AttributeList; |
35 |
import org.xml.sax.AttributeList; |
34 |
import org.xml.sax.helpers.AttributeListImpl; |
36 |
import org.xml.sax.helpers.AttributeListImpl; |
Lines 64-69
Link Here
|
64 |
*/ |
66 |
*/ |
65 |
private transient AttributeList attributes; |
67 |
private transient AttributeList attributes; |
66 |
|
68 |
|
|
|
69 |
// The following is set to true if any of the attributes are namespaced |
70 |
private transient boolean namespacedAttribute = false; |
71 |
|
67 |
/** Attribute names and values. While the XML spec doesn't require |
72 |
/** Attribute names and values. While the XML spec doesn't require |
68 |
* preserving the order ( AFAIK ), some ant tests do rely on the |
73 |
* preserving the order ( AFAIK ), some ant tests do rely on the |
69 |
* exact order. The following code is copied from AttributeImpl. |
74 |
* exact order. The following code is copied from AttributeImpl. |
Lines 119-125
Link Here
|
119 |
proxyConfigured = false; |
124 |
proxyConfigured = false; |
120 |
} |
125 |
} |
121 |
|
126 |
|
|
|
127 |
private static class EnableAttributeConsumer { |
128 |
public void add(EnableAttribute b) { |
129 |
// Ignore |
130 |
} |
131 |
} |
132 |
|
122 |
/** |
133 |
/** |
|
|
134 |
* Check if an UE is enabled. |
135 |
* This looks tru the attributes and checks if there |
136 |
* are any Ant attributes, and if so, the method calls the |
137 |
* isEnabled() method on them. |
138 |
* @param owner the UE that owns this RC. |
139 |
* @return true if enabled, false if any of the ant attribures return |
140 |
* false. |
141 |
*/ |
142 |
public boolean isEnabled(UnknownElement owner) { |
143 |
if (!namespacedAttribute) { |
144 |
return true; |
145 |
} |
146 |
ComponentHelper componentHelper = ComponentHelper |
147 |
.getComponentHelper(owner.getProject()); |
148 |
|
149 |
IntrospectionHelper ih |
150 |
= IntrospectionHelper.getHelper( |
151 |
owner.getProject(), EnableAttributeConsumer.class); |
152 |
for (int i = 0; i < attributeNames.size(); ++i) { |
153 |
String name = (String) attributeNames.get(i); |
154 |
if (name.indexOf(':') == -1) { |
155 |
continue; |
156 |
} |
157 |
String componentName = attrToComponent(name); |
158 |
String ns = ProjectHelper.extractUriFromComponentName(componentName); |
159 |
if (componentHelper.getRestrictedDefinitions( |
160 |
ProjectHelper.nsToComponentName(ns)) == null) { |
161 |
continue; |
162 |
} |
163 |
|
164 |
String value = (String) attributeMap.get(name); |
165 |
|
166 |
EnableAttribute enable = null; |
167 |
try { |
168 |
enable = (EnableAttribute) |
169 |
ih.createElement( |
170 |
owner.getProject(), new EnableAttributeConsumer(), |
171 |
componentName); |
172 |
} catch (BuildException ex) { |
173 |
throw new BuildException( |
174 |
"Unsupported attribute " + componentName); |
175 |
} |
176 |
if (enable == null) { |
177 |
continue; |
178 |
} |
179 |
value = owner.getProject().replaceProperties(value); // FixMe: need to make config |
180 |
if (!enable.isEnabled(owner, value)) { |
181 |
return false; |
182 |
} |
183 |
} |
184 |
return true; |
185 |
} |
186 |
|
187 |
private String attrToComponent(String a) { |
188 |
// need to remove the prefix |
189 |
int p1 = a.lastIndexOf(':'); |
190 |
int p2 = a.lastIndexOf(':', p1 - 1); |
191 |
return a.substring(0, p2) + a.substring(p1); |
192 |
} |
193 |
|
194 |
/** |
123 |
* Sets the creator of the element to be configured |
195 |
* Sets the creator of the element to be configured |
124 |
* used to store the element in the parent. |
196 |
* used to store the element in the parent. |
125 |
* |
197 |
* |
Lines 184-189
Link Here
|
184 |
* @param value the attribute's value. |
256 |
* @param value the attribute's value. |
185 |
*/ |
257 |
*/ |
186 |
public synchronized void setAttribute(String name, String value) { |
258 |
public synchronized void setAttribute(String name, String value) { |
|
|
259 |
if (name.indexOf(':') != -1) { |
260 |
namespacedAttribute = true; |
261 |
} |
187 |
if (name.equalsIgnoreCase(ProjectHelper.ANT_TYPE)) { |
262 |
if (name.equalsIgnoreCase(ProjectHelper.ANT_TYPE)) { |
188 |
this.polyType = value; |
263 |
this.polyType = value; |
189 |
} else { |
264 |
} else { |