ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant/util XMLFragment.java
Date Tue, 25 May 2004 08:25:01 GMT
peterreilly    2004/05/25 01:25:01

  Modified:    src/main/org/apache/tools/ant IntrospectionHelper.java
               src/main/org/apache/tools/ant/util XMLFragment.java
  Log:
  remove stephan's work-arounds
  
  Revision  Changes    Path
  1.83      +45 -46    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.82
  retrieving revision 1.83
  diff -u -r1.82 -r1.83
  --- IntrospectionHelper.java	25 May 2004 06:23:17 -0000	1.82
  +++ IntrospectionHelper.java	25 May 2004 08:25:00 -0000	1.83
  @@ -489,21 +489,20 @@
               = (AttributeSetter) attributeSetters.get(
                   attributeName.toLowerCase(Locale.US));
           if (as == null) {
  -//            if (element instanceof DynamicConfiguratorNS) {
  -//                DynamicConfiguratorNS dc = (DynamicConfiguratorNS) element;
  -//                String uriPlusPrefix =
  -//                    ProjectHelper.extractUriFromComponentName(attributeName);
  -//                String uri =
  -//                    ProjectHelper.extractUriFromComponentName(uriPlusPrefix);
  -//                String localName =
  -//                    ProjectHelper.extractNameFromComponentName(attributeName);
  -//                String qName = ("".equals(uri)
  -//                                ? localName : (uri + ":" + localName));
  -//
  -//                dc.setDynamicAttribute(uri, localName, qName, value);
  -//                return;
  -//            } else 
  -            if (element instanceof DynamicConfigurator) {
  +            if (element instanceof DynamicConfiguratorNS) {
  +                DynamicConfiguratorNS dc = (DynamicConfiguratorNS) element;
  +                String uriPlusPrefix =
  +                    ProjectHelper.extractUriFromComponentName(attributeName);
  +                String uri =
  +                    ProjectHelper.extractUriFromComponentName(uriPlusPrefix);
  +                String localName =
  +                    ProjectHelper.extractNameFromComponentName(attributeName);
  +                String qName = ("".equals(uri)
  +                                ? localName : (uri + ":" + localName));
  +
  +                dc.setDynamicAttribute(uri, localName, qName, value);
  +                return;
  +            } else if (element instanceof DynamicConfigurator) {
                   DynamicConfigurator dc = (DynamicConfigurator) element;
                   dc.setDynamicAttribute(attributeName.toLowerCase(Locale.US), value);
                   return;
  @@ -612,35 +611,35 @@
           if (nc == null) {
               nc = createAddTypeCreator(project, parent, elementName);
           }
  -//        if (nc == null && parent instanceof DynamicConfiguratorNS) {
  -//            DynamicConfiguratorNS dc = (DynamicConfiguratorNS) parent;
  -//            String qName = (child == null ? name : child.getQName());
  -//            final Object nestedElement =
  -//                dc.createDynamicElement(
  -//                    (child == null ? "" : child.getNamespace()),
  -//                    name, qName);
  -//            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 && parent instanceof DynamicConfiguratorNS) {
  +            DynamicConfiguratorNS dc = (DynamicConfiguratorNS) parent;
  +            String qName = (child == null ? name : child.getQName());
  +            final Object nestedElement =
  +                dc.createDynamicElement(
  +                    (child == null ? "" : child.getNamespace()),
  +                    name, qName);
  +            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 && parent instanceof DynamicConfigurator) {
               DynamicConfigurator dc = (DynamicConfigurator) parent;
               final Object nestedElement =
  @@ -751,7 +750,7 @@
       public boolean supportsNestedElement(String elementName) {
           return nestedCreators.containsKey(elementName.toLowerCase(Locale.US))
               || DynamicConfigurator.class.isAssignableFrom(bean)
  -            //            || DynamicConfiguratorNS.class.isAssignableFrom(bean)
  +            || DynamicConfiguratorNS.class.isAssignableFrom(bean)
               || addTypeMethods.size() != 0;
       }
   
  @@ -778,7 +777,7 @@
               nestedCreators.containsKey(name.toLowerCase(Locale.US))
               && (uri.equals(parentUri))) // || uri.equals("")))
               || DynamicConfigurator.class.isAssignableFrom(bean)
  -            //            || DynamicConfiguratorNS.class.isAssignableFrom(bean)
  +            || DynamicConfiguratorNS.class.isAssignableFrom(bean)
               || addTypeMethods.size() != 0;
       }
   
  
  
  
  1.8       +20 -36    ant/src/main/org/apache/tools/ant/util/XMLFragment.java
  
  Index: XMLFragment.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/XMLFragment.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- XMLFragment.java	25 May 2004 06:23:17 -0000	1.7
  +++ XMLFragment.java	25 May 2004 08:25:01 -0000	1.8
  @@ -24,8 +24,7 @@
   import org.w3c.dom.Text;
   
   import org.apache.tools.ant.BuildException;
  -//import org.apache.tools.ant.DynamicConfiguratorNS;
  -import org.apache.tools.ant.DynamicConfigurator;
  +import org.apache.tools.ant.DynamicConfiguratorNS;
   import org.apache.tools.ant.ProjectHelper;
   
   /**
  @@ -39,8 +38,7 @@
    *
    * @since Ant 1.7
    */
  -//public class XMLFragment implements DynamicConfiguratorNS {
  -public class XMLFragment implements DynamicConfigurator {
  +public class XMLFragment implements DynamicConfiguratorNS {
   
       private Document doc;
       private DocumentFragment fragment;
  @@ -68,8 +66,7 @@
       /**
        * No attributes for the wrapping element.
        */
  -    //    public void setDynamicAttribute(String uri, String name, String qName, String
value)
  -    public void setDynamicAttribute(String name, String value)
  +    public void setDynamicAttribute(String uri, String name, String qName, String value)
           throws BuildException {
           throw new BuildException("Attribute " + name + " is not supported.");
       }
  @@ -77,12 +74,8 @@
       /**
        * Creates a nested element.
        */
  -//    public Object createDynamicElement(String uri, String name, String qName) {
  -//        Element e = doc.createElementNS(uri, qName);
  -    public Object createDynamicElement(String name) {
  -        Element e = doc
  -            .createElementNS(ProjectHelper.extractUriFromComponentName(name),
  -                             ProjectHelper.extractNameFromComponentName(name));
  +    public Object createDynamicElement(String uri, String name, String qName) {
  +        Element e = doc.createElementNS(uri, qName);
           fragment.appendChild(e);
           return new Child(e);
       }
  @@ -94,8 +87,7 @@
           }
       }
   
  -    //    public class Child implements DynamicConfiguratorNS {
  -    public class Child implements DynamicConfigurator {
  +   public class Child implements DynamicConfiguratorNS {
           private Element e;
   
           Child(Element e) {
  @@ -112,33 +104,25 @@
           /**
            * Sets the attribute
            */
  -//        public void setDynamicAttribute(
  -//            String uri, String name, String qName, String value) {
  -//            if (uri.equals("")) {
  -//                e.setAttribute(name, value);
  -//            } else {
  -//                e.setAttributeNS(uri, qName, value);
  -//            }
  -        public void setDynamicAttribute(String name, String value) {
  -            e.setAttribute(name, value);
  +        public void setDynamicAttribute(
  +            String uri, String name, String qName, String value) {
  +            if (uri.equals("")) {
  +                e.setAttribute(name, value);
  +            } else {
  +                e.setAttributeNS(uri, qName, value);
  +            }
           }
   
           /**
            * Creates a nested element.
            */
  -//        public Object createDynamicElement(String uri, String name, String qName) {
  -//            Element e2 = null;
  -//            if (uri.equals("")) {
  -//                e2 = doc.createElement(name);
  -//            } else {
  -//                e2 = doc.createElementNS(uri, qName);
  -//            }
  -        public Object createDynamicElement(String name) {
  -            Element e2 = doc
  -                .createElementNS(ProjectHelper
  -                                 .extractUriFromComponentName(name),
  -                                 ProjectHelper
  -                                 .extractNameFromComponentName(name));
  +        public Object createDynamicElement(String uri, String name, String qName) {
  +            Element e2 = null;
  +            if (uri.equals("")) {
  +                e2 = doc.createElement(name);
  +            } else {
  +                e2 = doc.createElementNS(uri, qName);
  +            }
               e.appendChild(e2);
               return new Child(e2);
           }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message