peterreilly 2003/12/17 07:36:34 Modified: src/main/org/apache/tools/ant IntrospectionHelper.java UnknownElement.java src/main/org/apache/tools/ant/helper ProjectHelper2.java Log: * Retain difference between "" and "antlib:org.apache.tools.ant" namespaces in UE.getNamespace() * Remove near duplicate method in IntrospectionHelper * Add UnknownElement to signature of IntrospectionHelper#getElementCreator for future xml Namespace use Revision Changes Path 1.70 +5 -41 ant/src/main/org/apache/tools/ant/IntrospectionHelper.java Index: IntrospectionHelper.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/IntrospectionHelper.java,v retrieving revision 1.69 retrieving revision 1.70 diff -u -r1.69 -r1.70 --- IntrospectionHelper.java 11 Dec 2003 17:21:05 -0000 1.69 +++ IntrospectionHelper.java 17 Dec 2003 15:36:34 -0000 1.70 @@ -603,45 +603,6 @@ throw new BuildException(msg); } - private NestedCreator getNestedCreator(Project project, Object parent, - String elementName) throws BuildException { - - NestedCreator nc = (NestedCreator) nestedCreators.get( - elementName.toLowerCase(Locale.US)); - if (nc == null) { - nc = createAddTypeCreator(project, parent, elementName); - } - if (nc == null && parent instanceof DynamicConfigurator) { - DynamicConfigurator dc = (DynamicConfigurator) parent; - final Object nestedElement = dc.createDynamicElement(elementName); - if (nestedElement != null) { - nc = new NestedCreator() { - public boolean isPolyMorphic() { - return false; - } - public Class getElementClass() { - return null; - } - - public Object getRealObject() { - return null; - } - - public Object create( - Project project, Object parent, Object ignore) { - return nestedElement; - } - public void store(Object parent, Object child) { - } - }; - } - } - if (nc == null) { - throwNotSupported(project, parent, elementName); - } - return nc; - } - private NestedCreator getNestedCreator( Project project, String parentUri, Object parent, String elementName) throws BuildException { @@ -705,6 +666,7 @@ * Must not be <code>null</code>. * * @return an instance of the specified element type + * @deprecated This is not a namespace aware method. * * @exception BuildException if no method is available to create the * element instance, or if the creating method @@ -712,7 +674,7 @@ */ public Object createElement(Project project, Object parent, String elementName) throws BuildException { - NestedCreator nc = getNestedCreator(project, parent, elementName); + NestedCreator nc = getNestedCreator(project, "", parent, elementName); try { Object nestedElement = nc.create(project, parent, null); if (project != null) { @@ -743,11 +705,13 @@ * @param parent Parent object used to create the creator object to * create and store and instance of a subelement. * @param elementName Name of the element to create an instance of. + * @param ue The unknown element associated with the element. * @return a creator object to create and store the element instance. */ public Creator getElementCreator( - Project project, String parentUri, Object parent, String elementName) { + Project project, String parentUri, Object parent, String elementName, + UnknownElement ue) { NestedCreator nc = getNestedCreator( project, parentUri, parent, elementName); return new Creator(project, parent, nc); 1.71 +2 -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.70 retrieving revision 1.71 diff -u -r1.70 -r1.71 --- UnknownElement.java 24 Nov 2003 09:15:41 -0000 1.70 +++ UnknownElement.java 17 Dec 2003 15:36:34 -0000 1.71 @@ -564,7 +564,8 @@ child.getNamespace(), child.getTag()); if (ih.supportsNestedElement(parentUri, childName)) { IntrospectionHelper.Creator creator = - ih.getElementCreator(getProject(), parentUri, parent, childName); + ih.getElementCreator( + getProject(), parentUri, parent, childName, child); creator.setPolyType(childWrapper.getPolyType()); Object realChild = creator.create(); if (realChild instanceof PreSetDef.PreSetDefinition) { 1.38 +6 -10 ant/src/main/org/apache/tools/ant/helper/ProjectHelper2.java Index: ProjectHelper2.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/helper/ProjectHelper2.java,v retrieving revision 1.37 retrieving revision 1.38 diff -u -r1.37 -r1.38 --- ProjectHelper2.java 18 Nov 2003 17:06:58 -0000 1.37 +++ ProjectHelper2.java 17 Dec 2003 15:36:34 -0000 1.38 @@ -272,7 +272,7 @@ + buildFileName + " is invalid.", exc); } catch (IOException exc) { - throw new BuildException("Error reading project file " + throw new BuildException("Error reading project file " + buildFileName + ": " + exc.getMessage(), exc); } finally { @@ -484,9 +484,6 @@ */ public void startElement(String uri, String tag, String qname, Attributes attrs) throws SAXParseException { - if (uri.equals(ANT_CORE_URI)) { - uri = ""; - } AntHandler next = currentHandler.onStartChild(uri, tag, qname, attrs, context); antHandlers.push(currentHandler); @@ -519,9 +516,6 @@ * */ public void endElement(String uri, String name, String qName) throws SAXException { - if (uri.equals(ANT_CORE_URI)) { - uri = ""; - } currentHandler.onEndElement(uri, name, context); AntHandler prev = (AntHandler) antHandlers.pop(); currentHandler = prev; @@ -585,7 +579,8 @@ Attributes attrs, AntXMLContext context) throws SAXParseException { - if (name.equals("project") && uri.equals("")) { + if (name.equals("project") + && (uri.equals("") || uri.equals(ANT_CORE_URI))) { return ProjectHelper2.projectHandler; } else { // if (context.importlevel > 0) { @@ -653,7 +648,7 @@ } String key = attrs.getLocalName(i); String value = attrs.getValue(i); - + if (key.equals("default")) { if (value != null && !value.equals("")) { if (!context.isIgnoringProjectTag()) { @@ -756,7 +751,8 @@ Attributes attrs, AntXMLContext context) throws SAXParseException { - if (name.equals("target") && uri.equals("")) { + if (name.equals("target") + && (uri.equals("") || uri.equals(ANT_CORE_URI))) { return ProjectHelper2.targetHandler; } else { return ProjectHelper2.elementHandler;
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]