ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Xavier Hanin" <xavier.ha...@gmail.com>
Subject Re: svn commit: r629603 - /ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java
Date Thu, 21 Feb 2008 10:58:28 GMT
On Wed, Feb 20, 2008 at 9:31 PM, <maartenc@apache.org> wrote:

> Author: maartenc
> Date: Wed Feb 20 12:31:13 2008
> New Revision: 629603
>
> URL: http://svn.apache.org/viewvc?rev=629603&view=rev
> Log:
> Made this class JDK 1.4 compatible
>
> Modified:
>
>  ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java
>
> Modified:
> ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java
> URL:
> http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java?rev=629603&r1=629602&r2=629603&view=diff
>
> ==============================================================================
> ---
> ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java
> (original)
> +++
> ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java
> Wed Feb 20 12:31:13 2008
> @@ -177,7 +177,7 @@
>         }
>     }
>
> -    public Iterable/* <PomDependencyData> */ getDependencies() {
> +    public List /* <PomDependencyData> */ getDependencies() {
>         Element dependenciesElement = getFirstChildElement(projectElement,
> DEPENDENCIES);
>         LinkedList dependencies = new LinkedList();
>         if (dependenciesElement != null) {
> @@ -193,7 +193,7 @@
>     }
>
>
> -    public Iterable/* <PomDependencyMgt> */ getDependencyMgt() {
> +    public List /* <PomDependencyMgt> */ getDependencyMgt() {
>         Element dependenciesElement = getFirstChildElement(projectElement,
> DEPENDENCY_MGT);
>         dependenciesElement = getFirstChildElement(dependenciesElement,
> DEPENDENCIES);
>         LinkedList dependencies = new LinkedList();
> @@ -260,7 +260,7 @@
>             return getFirstChildElement(depElement, OPTIONAL) != null;
>         }
>
> -        public Iterable/*<ModuleId>*/ getExcludedModules() {
> +        public List /*<ModuleId>*/ getExcludedModules() {
>             Element exclusionsElement = getFirstChildElement(depElement,
> EXCLUSIONS);
>             LinkedList exclusions = new LinkedList();
>             if (exclusionsElement != null) {
> @@ -290,7 +290,7 @@
>         }
>         for (Iterator it = getAllChilds(propsEl).iterator(); it.hasNext();)
> {
>             Element prop = (Element) it.next();
> -            pomProperties.put(prop.getNodeName(), prop.getTextContent());
> +            pomProperties.put(prop.getNodeName(), getTextContent(prop));
>         }
>         return pomProperties;
>     }
> @@ -304,18 +304,32 @@
>         }
>     }
>
> -
> +    private static String getTextContent(Element element) {
> +        StringBuffer result = new StringBuffer();
> +
> +        NodeList childNodes = element.getChildNodes();
> +        for (int i = 0; i < childNodes.getLength(); i++) {
> +            Node child = childNodes.item(i);
> +
> +            switch (child.getNodeType()) {
> +                case Node.CDATA_SECTION_NODE:
> +                case Node.TEXT_NODE:
> +                    result.append(child.getNodeValue());
> +                    break;
> +            }
> +        }
> +
> +        return result.toString();
> +    }

Maybe this could go in XMLHelper instead? With a comment telling it
corresponds to Node#getTextContent() from DOM level 3?

Xavier


>
>
>     private static String getFirstChildText(Element parentElem, String
> name) {
>         Element node = getFirstChildElement(parentElem, name);
>         if (node != null) {
> -            node.normalize();
> -            return node.getTextContent();
> +            return getTextContent(node);
>         } else {
>             return null;
>         }
>     }
> -
>
>     private static Element getFirstChildElement(Element parentElem, String
> name) {
>         if (parentElem == null) {
>
>
>


-- 
Xavier Hanin - Independent Java Consultant
http://xhab.blogspot.com/
http://ant.apache.org/ivy/
http://www.xoocode.org/

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message