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 2005/12/05 18:13:34 UTC

svn commit: r354102 - in /incubator/woden/java/src/org/apache/woden: internal/Messages.properties internal/wsdl20/extensions/PopulatedExtensionRegistry.java internal/xml/QNameListAttrImpl.java xml/QNameListAttr.java

Author: jkaputin
Date: Mon Dec  5 09:13:21 2005
New Revision: 354102

URL: http://svn.apache.org/viewcvs?rev=354102&view=rev
Log:
Added a QNameListAttr type for handling attributes
of type 'xs:list of QNames'.

Added:
    incubator/woden/java/src/org/apache/woden/internal/xml/QNameListAttrImpl.java
    incubator/woden/java/src/org/apache/woden/xml/QNameListAttr.java
Modified:
    incubator/woden/java/src/org/apache/woden/internal/Messages.properties
    incubator/woden/java/src/org/apache/woden/internal/wsdl20/extensions/PopulatedExtensionRegistry.java

Modified: incubator/woden/java/src/org/apache/woden/internal/Messages.properties
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/Messages.properties?rev=354102&r1=354101&r2=354102&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/Messages.properties (original)
+++ incubator/woden/java/src/org/apache/woden/internal/Messages.properties Mon Dec  5 09:13:21 2005
@@ -59,6 +59,8 @@
 WSDL506=Could not create a URI from the string "{0}".
 WSDL507=Could not create a QName from the string "{0}".
 WSDL508=Could not create a String from a null value.
+WSDL509=Could not create a list of QNames from the string "{0}".
+WSDL510=Could not create a QName from the string "{0}" within the string of QNames "{1}".
 
 # ------------ TODO determine if these errors are needed -------------------
 

Modified: incubator/woden/java/src/org/apache/woden/internal/wsdl20/extensions/PopulatedExtensionRegistry.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/wsdl20/extensions/PopulatedExtensionRegistry.java?rev=354102&r1=354101&r2=354102&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/wsdl20/extensions/PopulatedExtensionRegistry.java (original)
+++ incubator/woden/java/src/org/apache/woden/internal/wsdl20/extensions/PopulatedExtensionRegistry.java Mon Dec  5 09:13:21 2005
@@ -17,6 +17,7 @@
 
 import org.apache.woden.internal.wsdl20.extensions.soap.SOAPConstants;
 import org.apache.woden.internal.xml.QNameAttrImpl;
+import org.apache.woden.internal.xml.QNameListAttrImpl;
 import org.apache.woden.internal.xml.StringAttrImpl;
 import org.apache.woden.internal.xml.URIAttrImpl;
 import org.apache.woden.wsdl20.extensions.ExtensionRegistry;
@@ -49,18 +50,17 @@
             BindingElement.class, SOAPConstants.Q_ATTR_SOAP_PROTOCOL, URIAttrImpl.class);
           
         registerExtAttributeType(
-                BindingElement.class, SOAPConstants.Q_ATTR_SOAP_MEPDEFAULT, URIAttrImpl.class);
+            BindingElement.class, SOAPConstants.Q_ATTR_SOAP_MEPDEFAULT, URIAttrImpl.class);
            
         //TODO Attr impl class to handle union of QName or xs:token
         registerExtAttributeType(
             BindingFaultElement.class, SOAPConstants.Q_ATTR_SOAP_CODE, QNameAttrImpl.class);
         
-        //TODO Attr impl class to handle list of QNames
-        //registerExtAttributeType(
-        //        BindingFaultElement.class, SOAPConstants.Q_ATTR_SOAP_SUBCODES, QNameListAttrImpl.class);
+        registerExtAttributeType(
+            BindingFaultElement.class, SOAPConstants.Q_ATTR_SOAP_SUBCODES, QNameListAttrImpl.class);
             
         registerExtAttributeType(
-                BindingOperationElement.class, SOAPConstants.Q_ATTR_SOAP_MEP, URIAttrImpl.class);
+            BindingOperationElement.class, SOAPConstants.Q_ATTR_SOAP_MEP, URIAttrImpl.class);
             
         registerExtAttributeType(
                 BindingOperationElement.class, SOAPConstants.Q_ATTR_SOAP_ACTION, URIAttrImpl.class);

Added: incubator/woden/java/src/org/apache/woden/internal/xml/QNameListAttrImpl.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/xml/QNameListAttrImpl.java?rev=354102&view=auto
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/xml/QNameListAttrImpl.java (added)
+++ incubator/woden/java/src/org/apache/woden/internal/xml/QNameListAttrImpl.java Mon Dec  5 09:13:21 2005
@@ -0,0 +1,114 @@
+/**
+ * Copyright 2005 Apache Software Foundation 
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); 
+ * you may not use this file except in compliance with the License. 
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+package org.apache.woden.internal.xml;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import javax.xml.namespace.QName;
+
+import org.apache.woden.ErrorReporter;
+import org.apache.woden.WSDLException;
+import org.apache.woden.internal.ErrorLocatorImpl;
+import org.apache.woden.internal.util.StringUtils;
+import org.apache.woden.internal.util.dom.DOMUtils;
+import org.apache.woden.xml.QNameListAttr;
+import org.w3c.dom.Element;
+
+
+/**
+ * This class represents XML attribute information items of type xs:list of QNames.
+ * 
+ * @author jkaputin@apache.org
+ */
+public class QNameListAttrImpl extends XMLAttrImpl implements QNameListAttr 
+{
+    public QNameListAttrImpl() {}
+    
+    /*
+     * TODO This ctor is not used for extension attributes, but may be useful if
+     * parsing of native WSDL attributes is changed to use the XMLAttr interface.
+     */
+    public QNameListAttrImpl(Element ownerEl, String qnValue, ErrorReporter errRpt) 
+                         throws WSDLException
+    {
+        super(ownerEl, qnValue, errRpt);
+    }
+    
+    /* ************************************************************
+     *  QNameAttr interface declared methods 
+     * ************************************************************/
+    
+    public QName[] getQNames() {
+        return (QName[])getContent();
+    }
+    
+    /* ************************************************************
+     *  Non-API implementation methods 
+     * ************************************************************/
+
+    /*
+     * Convert a string of type 'xs:list of QNames' to a java.xml.namespace.QName[].
+     * A a null argument will return a null value.
+     * If a QName string in the list causes a conversion error, it will be reported 
+     * and that QName will not appear in the array. Valid QName strings will still
+     * be converted, but the object will be marked invalid. If no QName strings can
+     * be converted, a null value will be returned.
+     */
+    protected Object convert(Element ownerEl, String qnamesString) throws WSDLException
+    {
+        if(qnamesString == null || "".equals(qnamesString))
+        {
+            getErrorReporter().reportError(
+                    new ErrorLocatorImpl(),  //TODO line&col nos.
+                    "WSDL509", 
+                    new Object[] {qnamesString}, 
+                    ErrorReporter.SEVERITY_ERROR);
+            return null;
+        }
+        
+        List qnStrings = StringUtils.parseNMTokens(qnamesString);
+        Iterator i = qnStrings.iterator();
+        String qnString = null;
+        QName qname = null;
+        List qnames = new Vector();
+        
+        while(i.hasNext())
+        {
+            qnString = (String)i.next();
+            try
+            {
+                qname = DOMUtils.getQName(qnString, ownerEl);
+            } 
+            catch (WSDLException e) 
+            {
+                getErrorReporter().reportError(
+                        new ErrorLocatorImpl(),  //TODO line&col nos.
+                        "WSDL510", 
+                        new Object[] {qnString, qnamesString}, 
+                        ErrorReporter.SEVERITY_ERROR, 
+                        e);
+                continue;
+            }
+            qnames.add(qname);
+        }
+        QName[] qnArray = new QName[qnames.size()];
+        qnames.toArray(qnArray);
+        return qnArray;
+    }
+
+}

Added: incubator/woden/java/src/org/apache/woden/xml/QNameListAttr.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/xml/QNameListAttr.java?rev=354102&view=auto
==============================================================================
--- incubator/woden/java/src/org/apache/woden/xml/QNameListAttr.java (added)
+++ incubator/woden/java/src/org/apache/woden/xml/QNameListAttr.java Mon Dec  5 09:13:21 2005
@@ -0,0 +1,29 @@
+/**
+ * Copyright 2005 Apache Software Foundation 
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); 
+ * you may not use this file except in compliance with the License. 
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+package org.apache.woden.xml;
+
+import javax.xml.namespace.QName;
+
+/**
+ * This interface represents XML attribute information items of type 
+ * xs:list of QNames.
+ * 
+ * @author jkaputin@apache.org
+ */
+public interface QNameListAttr extends XMLAttr 
+{
+    public QName[] getQNames();
+}



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