peterreilly 2003/10/14 01:47:42
Modified: src/main/org/apache/tools/ant UnknownElement.java
src/testcases/org/apache/tools/ant/types AddTypeTest.java
src/etc/testcases/types addtype.xml
Log:
Fix bug for typedefed add() support with namespace
Revision Changes Path
1.65 +30 -1 ant/src/main/org/apache/tools/ant/UnknownElement.java
Index: UnknownElement.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/UnknownElement.java,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- UnknownElement.java 26 Sep 2003 10:16:02 -0000 1.64
+++ UnknownElement.java 14 Oct 2003 08:47:40 -0000 1.65
@@ -57,6 +57,7 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Locale;
import java.io.IOException;
@@ -107,6 +108,31 @@
}
/**
+ * Makes a new unknown element based on this unknownelement
+ * does not copy the children
+ */
+ public UnknownElement copyItem() {
+ UnknownElement ret = new UnknownElement(getTag());
+ ret.setNamespace(getNamespace());
+ ret.setProject(getProject());
+ ret.setQName(getQName());
+ ret.setTaskName(getTaskName());
+ ret.setLocation(getLocation());
+ ret.setOwningTarget(getOwningTarget());
+ RuntimeConfigurable rc = new RuntimeConfigurable(
+ ret, getTaskName());
+ rc.setPolyType(getWrapper().getPolyType());
+ Map map = getWrapper().getAttributeMap();
+ for (Iterator i = map.entrySet().iterator(); i.hasNext();) {
+ Map.Entry entry = (Map.Entry) i.next();
+ rc.setAttribute(
+ (String) entry.getKey(),(String) entry.getValue());
+ }
+ rc.addText(getWrapper().getText().toString());
+ return ret;
+ }
+
+ /**
* Returns the name of the XML element which generated this unknown
* element.
*
@@ -518,7 +544,10 @@
// backwards compatibility - element names of nested
// elements have been all lower-case in Ant, except for
// TaskContainers
- String childName = child.getTag().toLowerCase(Locale.US);
+ // This does not work too good for typedefed elements...
+ String childName =
+ ProjectHelper.genComponentName(
+ child.getNamespace(), child.getTag().toLowerCase(Locale.US));
if (ih.supportsNestedElement(childName)) {
IntrospectionHelper.Creator creator =
ih.getElementCreator(getProject(), parent, childName);
1.4 +5 -0
ant/src/testcases/org/apache/tools/ant/types/AddTypeTest.java
Index: AddTypeTest.java
===================================================================
RCS file:
/home/cvs/ant/src/testcases/org/apache/tools/ant/types/AddTypeTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AddTypeTest.java 23 Jul 2003 12:13:58 -0000 1.3
+++ AddTypeTest.java 14 Oct 2003 08:47:41 -0000 1.4
@@ -123,6 +123,11 @@
expectLogContaining(
"myaddconfigured", "value is Value Setexecute: value is Value
Set");
}
+
+ public void testNamespace() {
+ executeTarget("namespacetest");
+ }
+
// The following will be used as types and tasks
public static interface A {}
1.3 +13 -3 ant/src/etc/testcases/types/addtype.xml
Index: addtype.xml
===================================================================
RCS file: /home/cvs/ant/src/etc/testcases/types/addtype.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- addtype.xml 23 Jul 2003 12:13:58 -0000 1.2
+++ addtype.xml 14 Oct 2003 08:47:42 -0000 1.3
@@ -70,7 +70,7 @@
<typedef loaderref="nested.loader" classpathref="nested.classes"
name = "myvalue"
classname="${nested.package}AddTypeTest$MyValue"/>
- </target>
+ </target>
<target name="nested.a" depends="init">
<nested.container>
@@ -83,7 +83,7 @@
<nested.b/>
</nested.container>
</target>
-
+
<target name="nested.c" depends="init">
<nested.container>
<nested.c/>
@@ -102,18 +102,21 @@
<nested.condition.type/>
<echo>after</echo>
</target>
+
<target name="condition.task" depends="init">
<echo>before</echo>
<nested.condition.task/>
<echo>after</echo>
</target>
+
<target name="condition.condition.type" depends="init">
<condition property="condition.condition.type">
<nested.condition.type/>
</condition>
</target>
+
<target name="condition.condition.task" depends="init">
- <condition property="condition.condition.task">>
+ <condition property="condition.condition.task">
<nested.condition.task/>
</condition>
</target>
@@ -124,4 +127,11 @@
</myaddconfigured>
</target>
+ <target name="namespacetest" xmlns:prefix="uri">
+ <typedef name="eq" uri="uri"
+ classname="org.apache.tools.ant.taskdefs.condition.Equals"/>
+ <condition property="p">
+ <prefix:eq arg1="a" arg2="b"/>
+ </condition>
+ </target>
</project>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]