You are viewing a plain text version of this content. The canonical link for it is here.
Posted to woden-dev@ws.apache.org by jk...@apache.org on 2006/10/18 17:24:48 UTC

svn commit: r465274 - in /incubator/woden/branches/WODEN-44/src/org/apache/woden: XMLElement.java internal/BaseWSDLReader.java internal/BaseXMLElement.java internal/DOMXMLElement.java

Author: jkaputin
Date: Wed Oct 18 08:24:48 2006
New Revision: 465274

URL: http://svn.apache.org/viewvc?view=rev&rev=465274
Log:
Added method getChildElements to XMLElement and
implemented it in BaseXMLElement and DOMXMLElement.
Changed BaseWSDLReader to use this new method
instead of getFirstChildElement/getNextSiblingElement.

Modified:
    incubator/woden/branches/WODEN-44/src/org/apache/woden/XMLElement.java
    incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/BaseWSDLReader.java
    incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/BaseXMLElement.java
    incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/DOMXMLElement.java

Modified: incubator/woden/branches/WODEN-44/src/org/apache/woden/XMLElement.java
URL: http://svn.apache.org/viewvc/incubator/woden/branches/WODEN-44/src/org/apache/woden/XMLElement.java?view=diff&rev=465274&r1=465273&r2=465274
==============================================================================
--- incubator/woden/branches/WODEN-44/src/org/apache/woden/XMLElement.java (original)
+++ incubator/woden/branches/WODEN-44/src/org/apache/woden/XMLElement.java Wed Oct 18 08:24:48 2006
@@ -100,7 +100,7 @@
     public QName getQName(String prefixedValue) throws WSDLException;
 
     /**
-     * Return the first child element of the given element. Null if no
+     * Return the first child element of this element or null if no
      * children are found.
      *
      * @return the first child element.
@@ -108,13 +108,20 @@
     public XMLElement getFirstChildElement();
 
     /**
-     * Return the next sibling element of the given element. Null if no
+     * Return the next sibling element of this element or null if no
      * siblings are found.
      *
      * @return the next sibling element.
      */
     public XMLElement getNextSiblingElement();
 
-    //TODO - other methods for accessing the element's contents?
+    /**
+     * Return an array of the child elements of this element or
+     * an empty array if no siblings are found.
+     *
+     * @return an XMLElement array containing the child elements.
+     */
+    public XMLElement[] getChildElements();
+
 
 }

Modified: incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/BaseWSDLReader.java
URL: http://svn.apache.org/viewvc/incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/BaseWSDLReader.java?view=diff&rev=465274&r1=465273&r2=465274
==============================================================================
--- incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/BaseWSDLReader.java (original)
+++ incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/BaseWSDLReader.java Wed Oct 18 08:24:48 2006
@@ -350,12 +350,14 @@
         parseExtensionAttributes(descEl, DescriptionElement.class, desc, desc);
         
         //parse the child elements
-        XMLElement tempEl = descEl.getFirstChildElement();
+        XMLElement[] children = descEl.getChildElements();
+        XMLElement tempEl = null;
         QName tempElQN = null;
 
-        while (tempEl != null)
+        for(int i=0; i<children.length; i++)
         {
-        	tempElQN = tempEl.getQName();
+            tempEl = children[i];
+            tempElQN = tempEl.getQName();
         	
             if (Constants.Q_ELEM_DOCUMENTATION.equals(tempElQN))
             {
@@ -398,8 +400,6 @@
                 desc.addExtensionElement(
                     parseExtensionElement(DescriptionElement.class, desc, tempEl, desc) );
             }
-            
-            tempEl = tempEl.getNextSiblingElement();
         }
         
         parseSchemaForXMLSchema(desc);  //TODO temporary - see comments within the method
@@ -422,14 +422,14 @@
 
         parseExtensionAttributes(docEl, DocumentationElement.class, documentation, desc);
 
-        XMLElement tempEl = docEl.getFirstChildElement();
+        XMLElement[] children = docEl.getChildElements();
+        XMLElement tempEl = null;
 
-        while (tempEl != null)
+        for(int i=0; i<children.length; i++)
         {
+            tempEl = children[i];
             documentation.addExtensionElement(
                     parseExtensionElement(DocumentationElement.class, documentation, tempEl, desc) );
-
-            tempEl = tempEl.getNextSiblingElement();
         }
 
         return documentation;
@@ -506,11 +506,13 @@
 
         parseExtensionAttributes(typesEl, TypesElement.class, types, desc);
 
-        XMLElement tempEl = typesEl.getFirstChildElement();
+        XMLElement[] children = typesEl.getChildElements();
+        XMLElement tempEl = null;
         QName tempElQN = null;
 
-        while (tempEl != null)
+        for(int i=0; i<children.length; i++)
         {
+            tempEl = children[i];
             tempElQN = tempEl.getQName();
 
             //TODO validate element order? <documentation> must be first.
@@ -532,8 +534,6 @@
                 types.addExtensionElement(
                         parseExtensionElement(TypesElement.class, types, tempEl, desc) );
             }
-
-            tempEl = tempEl.getNextSiblingElement();
         }
 
         return types;
@@ -598,11 +598,13 @@
          * TODO validate that the elements are in correct order
          */ 
 
-        XMLElement tempEl = interfaceEl.getFirstChildElement();
+        XMLElement[] children = interfaceEl.getChildElements();
+        XMLElement tempEl = null;
         QName tempElQN = null;
 
-        while (tempEl != null)
+        for(int i=0; i<children.length; i++)
         {
+            tempEl = children[i];
             tempElQN = tempEl.getQName();
 
             if (Constants.Q_ELEM_DOCUMENTATION.equals(tempElQN))
@@ -630,8 +632,6 @@
                 intface.addExtensionElement(
                         parseExtensionElement(InterfaceElement.class, intface, tempEl, desc) );
             }
-
-            tempEl = tempEl.getNextSiblingElement();
         }
 
         return intface;
@@ -676,11 +676,13 @@
 
         parseExtensionAttributes(faultEl, InterfaceFaultElement.class, fault, desc);
 
-        XMLElement tempEl = faultEl.getFirstChildElement();
+        XMLElement[] children = faultEl.getChildElements();
+        XMLElement tempEl = null;
         QName tempElQN = null;
 
-        while (tempEl != null)
+        for(int i=0; i<children.length; i++)
         {
+            tempEl = children[i];
             tempElQN = tempEl.getQName();
 
             if (Constants.Q_ELEM_DOCUMENTATION.equals(tempElQN))
@@ -700,8 +702,6 @@
                 fault.addExtensionElement(
                         parseExtensionElement(InterfaceFaultElement.class, fault, tempEl, desc) );
             }
-
-            tempEl = tempEl.getNextSiblingElement();
         }
 
         return fault;
@@ -750,11 +750,13 @@
          * TODO validate that the elements are in correct order
          */ 
 
-        XMLElement tempEl = operEl.getFirstChildElement();
+        XMLElement[] children = operEl.getChildElements();
+        XMLElement tempEl = null;
         QName tempElQN = null;
 
-        while (tempEl != null)
+        for(int i=0; i<children.length; i++)
         {
+            tempEl = children[i];
             tempElQN = tempEl.getQName();
 
             if (Constants.Q_ELEM_DOCUMENTATION.equals(tempElQN))
@@ -790,8 +792,6 @@
                 oper.addExtensionElement(
                         parseExtensionElement(InterfaceOperationElement.class, oper, tempEl, desc) );
             }
-
-            tempEl = tempEl.getNextSiblingElement();
         }
 
         return oper;
@@ -836,11 +836,13 @@
 
         parseExtensionAttributes(faultRefEl, InterfaceFaultReferenceElement.class, faultRef, desc);
 
-        XMLElement tempEl = faultRefEl.getFirstChildElement();
+        XMLElement[] children = faultRefEl.getChildElements();
+        XMLElement tempEl = null;
         QName tempElQN = null;
 
-        while (tempEl != null)
+        for(int i=0; i<children.length; i++)
         {
+            tempEl = children[i];
             tempElQN = tempEl.getQName();
 
             if (Constants.Q_ELEM_DOCUMENTATION.equals(tempElQN))
@@ -860,8 +862,6 @@
                 faultRef.addExtensionElement(
                         parseExtensionElement(InterfaceFaultReferenceElement.class, faultRef, tempEl, desc) );
             }
-
-            tempEl = tempEl.getNextSiblingElement();
         }
 
         return faultRef;
@@ -935,11 +935,13 @@
 
         parseExtensionAttributes(msgRefEl, InterfaceMessageReferenceElement.class, message, desc);
 
-        XMLElement tempEl = msgRefEl.getFirstChildElement();
+        XMLElement[] children = msgRefEl.getChildElements();
+        XMLElement tempEl = null;
         QName tempElQN = null;
 
-        while (tempEl != null)
+        for(int i=0; i<children.length; i++)
         {
+            tempEl = children[i];
             tempElQN = tempEl.getQName();
 
             if (Constants.Q_ELEM_DOCUMENTATION.equals(tempElQN))
@@ -959,8 +961,6 @@
                 message.addExtensionElement(
                         parseExtensionElement(InterfaceMessageReferenceElement.class, message, tempEl, desc) );
             }
-
-            tempEl = tempEl.getNextSiblingElement();
         }
 
         return message;
@@ -1009,11 +1009,13 @@
          * TODO validate that the elements are in correct order
          */ 
 
-        XMLElement tempEl = bindEl.getFirstChildElement();
+        XMLElement[] children = bindEl.getChildElements();
+        XMLElement tempEl = null;
         QName tempElQN = null;
 
-        while (tempEl != null)
+        for(int i=0; i<children.length; i++)
         {
+            tempEl = children[i];
             tempElQN = tempEl.getQName();
 
             if (Constants.Q_ELEM_DOCUMENTATION.equals(tempElQN))
@@ -1041,8 +1043,6 @@
                 binding.addExtensionElement(
                         parseExtensionElement(BindingElement.class, binding, tempEl, desc) );
             }
-
-            tempEl = tempEl.getNextSiblingElement();
         }
 
         return binding;
@@ -1081,11 +1081,13 @@
          * TODO validate that the elements are in correct order
          */ 
 
-        XMLElement tempEl = bindFaultEl.getFirstChildElement();
+        XMLElement[] children = bindFaultEl.getChildElements();
+        XMLElement tempEl = null;
         QName tempElQN = null;
 
-        while (tempEl != null)
+        for(int i=0; i<children.length; i++)
         {
+            tempEl = children[i];
             tempElQN = tempEl.getQName();
 
             if (Constants.Q_ELEM_DOCUMENTATION.equals(tempElQN))
@@ -1105,8 +1107,6 @@
                 fault.addExtensionElement(
                         parseExtensionElement(BindingFaultElement.class, fault, tempEl, desc) );
             }
-
-            tempEl = tempEl.getNextSiblingElement();
         }
 
         return fault;
@@ -1146,11 +1146,13 @@
          * TODO validate that the elements are in correct order
          */ 
 
-        XMLElement tempEl = bindOpEl.getFirstChildElement();
+        XMLElement[] children = bindOpEl.getChildElements();
+        XMLElement tempEl = null;
         QName tempElQN = null;
 
-        while (tempEl != null)
+        for(int i=0; i<children.length; i++)
         {
+            tempEl = children[i];
             tempElQN = tempEl.getQName();
 
             if (Constants.Q_ELEM_DOCUMENTATION.equals(tempElQN))
@@ -1186,8 +1188,6 @@
                 oper.addExtensionElement(
                         parseExtensionElement(BindingOperationElement.class, oper, tempEl, desc) );
             }
-
-            tempEl = tempEl.getNextSiblingElement();
         }
 
         return oper;
@@ -1233,11 +1233,13 @@
          * TODO validate that the elements are in correct order
          */ 
 
-        XMLElement tempEl = faultRefEl.getFirstChildElement();
+        XMLElement[] children = faultRefEl.getChildElements();
+        XMLElement tempEl = null;
         QName tempElQN = null;
 
-        while (tempEl != null)
+        for(int i=0; i<children.length; i++)
         {
+            tempEl = children[i];
             tempElQN = tempEl.getQName();
 
             if (Constants.Q_ELEM_DOCUMENTATION.equals(tempElQN))
@@ -1257,8 +1259,6 @@
                 faultRef.addExtensionElement(
                         parseExtensionElement(BindingFaultReferenceElement.class, faultRef, tempEl, desc) );
             }
-
-            tempEl = tempEl.getNextSiblingElement();
         }
 
         return faultRef;
@@ -1307,11 +1307,13 @@
          * TODO validate that the elements are in correct order
          */ 
 
-        XMLElement tempEl = msgRefEl.getFirstChildElement();
+        XMLElement[] children = msgRefEl.getChildElements();
+        XMLElement tempEl = null;
         QName tempElQN = null;
 
-        while (tempEl != null)
+        for(int i=0; i<children.length; i++)
         {
+            tempEl = children[i];
             tempElQN = tempEl.getQName();
 
             if (Constants.Q_ELEM_DOCUMENTATION.equals(tempElQN))
@@ -1331,8 +1333,6 @@
                 message.addExtensionElement(
                         parseExtensionElement(BindingMessageReferenceElement.class, message, tempEl, desc) );
             }
-
-            tempEl = tempEl.getNextSiblingElement();
         }
 
         return message;
@@ -1377,12 +1377,14 @@
 		 * TODO validate that the elements are in correct order
 		 */ 
 
-		XMLElement tempEl = serviceEl.getFirstChildElement();
-		QName tempElQN = null;
+        XMLElement[] children = serviceEl.getChildElements();
+        XMLElement tempEl = null;
+        QName tempElQN = null;
 
-		while (tempEl != null)
-		{
-			tempElQN = tempEl.getQName();
+        for(int i=0; i<children.length; i++)
+        {
+            tempEl = children[i];
+            tempElQN = tempEl.getQName();
 
 			if (Constants.Q_ELEM_DOCUMENTATION.equals(tempElQN))
 			{
@@ -1405,8 +1407,6 @@
 				service.addExtensionElement(
 						parseExtensionElement(ServiceElement.class, service, tempEl, desc) );
 			}
-
-			tempEl = tempEl.getNextSiblingElement();
 		}
 
 		return service;
@@ -1459,11 +1459,13 @@
          * TODO validate that the elements are in correct order
          */ 
 
-        XMLElement tempEl = endpointEl.getFirstChildElement();
+        XMLElement[] children = endpointEl.getChildElements();
+        XMLElement tempEl = null;
         QName tempElQN = null;
 
-        while (tempEl != null)
+        for(int i=0; i<children.length; i++)
         {
+            tempEl = children[i];
             tempElQN = tempEl.getQName();
 
             if (Constants.Q_ELEM_DOCUMENTATION.equals(tempElQN))
@@ -1483,8 +1485,6 @@
                 endpoint.addExtensionElement(
                         parseExtensionElement(ServiceElement.class, endpoint, tempEl, desc) );
             }
-
-            tempEl = tempEl.getNextSiblingElement();
         }
 
         return endpoint;
@@ -1518,11 +1518,15 @@
          * TODO validate that the elements are in correct order
          */ 
 
-        XMLElement tempEl = featEl.getFirstChildElement();
+        XMLElement[] children = featEl.getChildElements();
+        XMLElement tempEl = null;
+        QName tempElQN = null;
 
-        while (tempEl != null)
+        for(int i=0; i<children.length; i++)
         {
-            if (Constants.Q_ELEM_DOCUMENTATION.equals(tempEl.getQName()))
+            tempEl = children[i];
+            tempElQN = tempEl.getQName();
+            if (Constants.Q_ELEM_DOCUMENTATION.equals(tempElQN))
             {
                 parseDocumentation(tempEl, desc, feature);
             }
@@ -1531,8 +1535,6 @@
                 feature.addExtensionElement(
                         parseExtensionElement(FeatureElement.class, feature, tempEl, desc) );
             }
-
-            tempEl = tempEl.getNextSiblingElement();
         }
 
         return feature;

Modified: incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/BaseXMLElement.java
URL: http://svn.apache.org/viewvc/incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/BaseXMLElement.java?view=diff&rev=465274&r1=465273&r2=465274
==============================================================================
--- incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/BaseXMLElement.java (original)
+++ incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/BaseXMLElement.java Wed Oct 18 08:24:48 2006
@@ -158,5 +158,20 @@
     }
     
     protected abstract XMLElement doGetNextSiblingElement();
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.woden.XMLElement#getChildElements()
+     */
+    public final XMLElement[] getChildElements() {
+        
+        if(fSource != null) {
+            return doGetChildElements();
+        } else {
+            return null;
+        }
+    }
+    
+    protected abstract XMLElement[] doGetChildElements();
     
 }

Modified: incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/DOMXMLElement.java
URL: http://svn.apache.org/viewvc/incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/DOMXMLElement.java?view=diff&rev=465274&r1=465273&r2=465274
==============================================================================
--- incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/DOMXMLElement.java (original)
+++ incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/DOMXMLElement.java Wed Oct 18 08:24:48 2006
@@ -177,6 +177,20 @@
         return null;  //no sibling element found
     }
     
+    protected XMLElement[] doGetChildElements() {
+        
+        List children = new Vector();
+        XMLElement temp = doGetFirstChildElement();
+        while(temp != null)
+        {
+            children.add(temp);
+            temp = temp.getNextSiblingElement();
+        }
+        XMLElement[] array = new XMLElement[children.size()];
+        children.toArray(array);
+        return array;
+    }
+    
     /* ************************************************************************
      * Private helper methods
      * ************************************************************************/



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