Author: jkaputin
Date: Thu Oct 19 05:10:27 2006
New Revision: 465594

URL: http://svn.apache.org/viewvc?view=rev&rev=465594
Log:
Implemented in OMXMLElement the methods defined on
XMLElement and inherited as abstract methods
from BaseXMLElement. 

Modified:
    
incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/OMXMLElement.java

Modified: 
incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/OMXMLElement.java
URL: 
http://svn.apache.org/viewvc/incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/OMXMLElement.java?view=diff&rev=465594&r1=465593&r2=465594
==============================================================================
--- 
incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/OMXMLElement.java
 (original)
+++ 
incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/OMXMLElement.java
 Thu Oct 19 05:10:27 2006
@@ -16,15 +16,18 @@
 
 package org.apache.woden.internal;
 
-import org.apache.woden.WSDLException;
-import org.apache.woden.ErrorReporter;
-import org.apache.woden.XMLElement;
-import org.apache.axiom.om.OMElement;
-
-import javax.xml.namespace.QName;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Vector;
-import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.woden.ErrorReporter;
+import org.apache.woden.WSDLException;
+import org.apache.woden.XMLElement;
 
 public class OMXMLElement extends BaseXMLElement{
 
@@ -74,67 +77,100 @@
     }
      */
 
-    public String getAttributeValue(String attrName) {
-        if (fSource instanceof OMElement){
-            OMElement elem = (OMElement)fSource;
-            return elem.getAttributeValue(new QName(attrName));
-        }
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
+    protected String doGetAttributeValue(String attrName) {
+        OMElement elem = (OMElement)fSource;
+        return elem.getAttributeValue(new QName(attrName));
     }
 
-    public XMLElement getFirstChildElement() throws WSDLException {
-        if (fSource instanceof OMElement){
-            OMElement elem = (OMElement)fSource;
-            OMXMLElement omXMLElement = new OMXMLElement(getErrorReporter());
-            omXMLElement.setSource(elem.getFirstElement());
-            return omXMLElement;
-        }
-        return null;
-    }
-
-    public QName getQName(String prefixedValue) throws WSDLException {
-        if (fSource instanceof OMElement){
-            OMElement elem = (OMElement)fSource;
-            int index = prefixedValue.indexOf(':');
-            String prefix = (index != -1)
-                            ? prefixedValue.substring(0, index)
-                            : null;
-            String localPart    = prefixedValue.substring(index + 1);
-            String namespaceURI;
-
-            if (prefix != null){
-                namespaceURI = elem.findNamespaceURI(prefix).getNamespaceURI();
-                return new QName(namespaceURI,localPart,
-                        prefix);
-            }
-            else{
-                String faultCode = WSDLException.NO_PREFIX_SPECIFIED;
-
-                throw new WSDLException(faultCode,
-                        "Unable to determine " +
-                        "namespace of '" +
-                        prefixedValue + "'.");
-            }
-        }
-        return null;
-    }
-
-    public String getLocalName() {
-        if (fSource instanceof OMElement){
-            OMElement elem = (OMElement)fSource;
-            return elem.getLocalName();
-        }
-        return null;
-    }
+    protected URI doGetNamespaceURI() throws WSDLException {
+        OMElement elem = (OMElement)fSource;
+        String nsStr =  elem.getNamespace().getNamespaceURI();
+        URI uri = null;
+        try {
+            uri = new URI(nsStr);
+        } catch (URISyntaxException e) {
+            String msg = fErrorReporter.getFormattedMessage(
+                                            "WSDL506", 
+                                            new Object[] {nsStr});
+            throw new WSDLException(WSDLException.INVALID_WSDL, msg, e);
+        }
+        return uri;
+    }
+
+    protected String doGetLocalName() {
+        OMElement elem = (OMElement)fSource;
+        return elem.getLocalName();
+    }
+    
+    protected QName doGetQName() {
+        OMElement elem = (OMElement)fSource;
+        return elem.getQName();
+    }
+
+    protected QName doGetQName(String prefixedValue) throws WSDLException {
+        OMElement elem = (OMElement)fSource;
+        int index = prefixedValue.indexOf(':');
+        String prefix = (index != -1)
+                        ? prefixedValue.substring(0, index)
+                        : null;
+        String localPart    = prefixedValue.substring(index + 1);
+        String namespaceURI;
+
+        if (prefix != null){
+            namespaceURI = elem.findNamespaceURI(prefix).getNamespaceURI();
+            return new QName(namespaceURI,localPart,
+                    prefix);
+        }
+        else{
+            String faultCode = (prefix == null)
+            ? WSDLException.NO_PREFIX_SPECIFIED
+            : WSDLException.UNBOUND_PREFIX;
+    
+            String msg = fErrorReporter.getFormattedMessage(
+                    "WSDL513", 
+                    new Object[] {prefixedValue, elem.getQName()});
 
-    public XMLElement getNextSiblingElement() throws WSDLException {
-        if (fSource instanceof OMElement){
-            OMElement elem = (OMElement)fSource;
-            OMXMLElement omXMLElement = new OMXMLElement(getErrorReporter());
-            omXMLElement.setSource(elem.getNextOMSibling());
-            return omXMLElement;
+            WSDLException wsdlExc = new WSDLException(
+                    faultCode,
+                    msg);
+
+            //TODO wsdlExc.setLocation(XPathUtils.getXPathExprFromNode(el));
+
+            throw wsdlExc;
+        }
+        
+    }
+
+    protected XMLElement doGetFirstChildElement() {
+        OMElement elem = (OMElement)fSource;
+        OMXMLElement omXMLElement = new OMXMLElement(fErrorReporter);
+        omXMLElement.setSource(elem.getFirstElement());
+        return omXMLElement;
+    }
+
+    protected XMLElement doGetNextSiblingElement() {
+        OMElement elem = (OMElement)fSource;
+        OMXMLElement omXMLElement = new OMXMLElement(fErrorReporter);
+        omXMLElement.setSource(elem.getNextOMSibling());
+        return omXMLElement;
+    }
+        
+    protected XMLElement[] doGetChildElements() {
+        
+        OMElement elem = (OMElement)fSource;
+        Iterator elems = elem.getChildElements();
+        List children = new Vector();
+        Object next = elems.next();
+        while(next != null)
+        {
+            OMXMLElement omXMLElement = new OMXMLElement(fErrorReporter);
+            omXMLElement.setSource(next);
+            children.add(next);
+            next = elems.next();
         }
-        return null;
+        XMLElement[] array = new XMLElement[children.size()];
+        children.toArray(array);
+        return array;
     }
-
+    
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to