ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maart...@apache.org
Subject svn commit: r629603 - /ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java
Date Wed, 20 Feb 2008 20:31:15 GMT
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();
+    }
     
     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) {



Mime
View raw message