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 14:34:12 UTC

svn commit: r354068 - in /incubator/woden/java/src/org/apache/woden: internal/xml/ xml/

Author: jkaputin
Date: Mon Dec  5 05:33:56 2005
New Revision: 354068

URL: http://svn.apache.org/viewcvs?rev=354068&view=rev
Log:
Add interfaces and impl classes that represent the
various types of xml attribute values (uri, string,
qname, etc).

Added:
    incubator/woden/java/src/org/apache/woden/internal/xml/QNameAttrImpl.java
    incubator/woden/java/src/org/apache/woden/internal/xml/StringAttrImpl.java
    incubator/woden/java/src/org/apache/woden/internal/xml/URIAttrImpl.java
    incubator/woden/java/src/org/apache/woden/internal/xml/XMLAttrImpl.java
    incubator/woden/java/src/org/apache/woden/xml/QNameAttr.java
    incubator/woden/java/src/org/apache/woden/xml/StringAttr.java
    incubator/woden/java/src/org/apache/woden/xml/URIAttr.java
    incubator/woden/java/src/org/apache/woden/xml/XMLAttr.java

Added: incubator/woden/java/src/org/apache/woden/internal/xml/QNameAttrImpl.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/xml/QNameAttrImpl.java?rev=354068&view=auto
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/xml/QNameAttrImpl.java (added)
+++ incubator/woden/java/src/org/apache/woden/internal/xml/QNameAttrImpl.java Mon Dec  5 05:33:56 2005
@@ -0,0 +1,94 @@
+/**
+ * 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 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.dom.DOMUtils;
+import org.apache.woden.xml.QNameAttr;
+import org.w3c.dom.Element;
+
+
+/**
+ * This class represents XML attribute information items of type xs:QName.
+ * 
+ * @author jkaputin@apache.org
+ */
+public class QNameAttrImpl extends XMLAttrImpl implements QNameAttr 
+{
+    public QNameAttrImpl() {}
+    
+    /*
+     * 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 QNameAttrImpl(Element ownerEl, String qnValue, ErrorReporter errRpt) 
+                         throws WSDLException
+    {
+        super(ownerEl, qnValue, errRpt);
+    }
+    
+    /* ************************************************************
+     *  QNameAttr interface declared methods 
+     * ************************************************************/
+    
+    public QName getQName() {
+        return (QName)getContent();
+    }
+    
+    /* ************************************************************
+     *  Non-API implementation methods 
+     * ************************************************************/
+
+    /*
+     * Convert a string of type xs:QName to a java.xml.namespace.QName.
+     * A a null argument will return a null value.
+     * Any conversion error will be reported and a null value will be returned.
+     */
+    protected Object convert(Element ownerEl, String qnValue) throws WSDLException
+    {
+        Exception ex = null;
+        QName qn = null;
+        
+        if(qnValue != null)
+        {
+            try
+            {
+                qn = DOMUtils.getQName(qnValue, ownerEl);
+            } 
+            catch (WSDLException e) 
+            {
+                ex = e;
+            }
+        }
+        
+        if(qn == null)
+        {
+            getErrorReporter().reportError(
+                    new ErrorLocatorImpl(),  //TODO line&col nos.
+                    "WSDL507", 
+                    new Object[] {qnValue}, 
+                    ErrorReporter.SEVERITY_ERROR, 
+                    ex);
+        }
+        
+        return qn;
+    }
+
+}

Added: incubator/woden/java/src/org/apache/woden/internal/xml/StringAttrImpl.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/xml/StringAttrImpl.java?rev=354068&view=auto
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/xml/StringAttrImpl.java (added)
+++ incubator/woden/java/src/org/apache/woden/internal/xml/StringAttrImpl.java Mon Dec  5 05:33:56 2005
@@ -0,0 +1,77 @@
+/**
+ * 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 org.apache.woden.ErrorReporter;
+import org.apache.woden.WSDLException;
+import org.apache.woden.internal.ErrorLocatorImpl;
+import org.apache.woden.xml.StringAttr;
+import org.w3c.dom.Element;
+
+
+/**
+ * This class represents XML attribute information items of type xs:string.
+ * 
+ * @author jkaputin@apache.org
+ */
+public class StringAttrImpl extends XMLAttrImpl implements StringAttr 
+{
+    public StringAttrImpl() {}
+    
+    /*
+     * 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 StringAttrImpl(Element ownerEl, String strValue, ErrorReporter errRpt) 
+                       throws WSDLException
+    {
+        super(ownerEl, strValue, errRpt);
+    }
+    
+    /* ************************************************************
+     *  StringAttr interface declared methods 
+     * ************************************************************/
+    
+    public String getString() {
+        return (String)getContent();
+    }
+    
+    /* ************************************************************
+     *  Non-API implementation methods 
+     * ************************************************************/
+
+    /*
+     * Convert a string of type xs:string to a java.lang.String.
+     * A null argument will return a null value.
+     * Any conversion error will be reported and a null value will be returned.
+     */
+    protected Object convert(Element ownerEl, String strValue) throws WSDLException
+    {
+        Exception ex = null;
+        String str = strValue;
+        
+        if(str == null)
+        {
+            getErrorReporter().reportError(
+                    new ErrorLocatorImpl(),  //TODO line&col nos.
+                    "WSDL508", 
+                    new Object[] {strValue}, 
+                    ErrorReporter.SEVERITY_ERROR);
+        }
+        return str;
+    }
+
+}

Added: incubator/woden/java/src/org/apache/woden/internal/xml/URIAttrImpl.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/xml/URIAttrImpl.java?rev=354068&view=auto
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/xml/URIAttrImpl.java (added)
+++ incubator/woden/java/src/org/apache/woden/internal/xml/URIAttrImpl.java Mon Dec  5 05:33:56 2005
@@ -0,0 +1,94 @@
+/**
+ * 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.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.woden.ErrorReporter;
+import org.apache.woden.WSDLException;
+import org.apache.woden.internal.ErrorLocatorImpl;
+import org.apache.woden.xml.URIAttr;
+import org.w3c.dom.Element;
+
+
+/**
+ * This class represents XML attribute information items of type xs:anyURI.
+ * 
+ * @author jkaputin@apache.org
+ */
+public class URIAttrImpl extends XMLAttrImpl implements URIAttr 
+{
+    public URIAttrImpl() {}
+    
+    /*
+     * 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 URIAttrImpl(Element ownerEl, String uriValue, ErrorReporter errRpt) 
+                       throws WSDLException
+    {
+        super(ownerEl, uriValue, errRpt);
+    }
+    
+    /* ************************************************************
+     *  URIAttr interface declared methods 
+     * ************************************************************/
+    
+    public URI getURI() {
+        return (URI)getContent();
+    }
+    
+    /* ************************************************************
+     *  Non-API implementation methods 
+     * ************************************************************/
+
+    /*
+     * Convert a string of type xs:anyURI to a java.net.URI.
+     * An empty string argument will return an empty string URI.
+     * A null argument will return a null value.
+     * Any conversion error will be reported and a null value will be returned.
+     */
+    protected Object convert(Element ownerEl, String uriValue) throws WSDLException
+    {
+        Exception ex = null;
+        URI uri = null;
+        
+        if(uriValue != null)
+        {
+            try 
+            {
+                uri = new URI(uriValue);
+            } 
+            catch (URISyntaxException e) 
+            {
+                ex = e;
+            }
+        }
+        
+        if(uri == null)
+        {
+            getErrorReporter().reportError(
+                    new ErrorLocatorImpl(),  //TODO line&col nos.
+                    "WSDL506", 
+                    new Object[] {uriValue}, 
+                    ErrorReporter.SEVERITY_ERROR, 
+                    ex);
+        }
+        return uri;
+    }
+
+}

Added: incubator/woden/java/src/org/apache/woden/internal/xml/XMLAttrImpl.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/xml/XMLAttrImpl.java?rev=354068&view=auto
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/xml/XMLAttrImpl.java (added)
+++ incubator/woden/java/src/org/apache/woden/internal/xml/XMLAttrImpl.java Mon Dec  5 05:33:56 2005
@@ -0,0 +1,103 @@
+/**
+ * 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 org.apache.woden.ErrorReporter;
+import org.apache.woden.WSDLException;
+import org.apache.woden.internal.ErrorReporterImpl;
+import org.apache.woden.xml.XMLAttr;
+import org.w3c.dom.Element;
+
+
+/**
+ * This is an abstract superclass for all classes representing different
+ * types of XML attribute information items.
+ * 
+ * @author jkaputin@apache.org
+ */
+public abstract class XMLAttrImpl implements XMLAttr
+{
+    protected Object fContent = null;
+    protected String fExternalForm = null;
+    protected boolean fValid = false;
+    private ErrorReporter fErrorReporter = null;
+    
+    protected XMLAttrImpl() {}
+
+    /*
+     * This ctor is not used for extension attributes, but may be useful if
+     * parsing of native attributes is changed to use the XMLAttr interface.
+     */
+    protected XMLAttrImpl(Element ownerEl, String attrValue, ErrorReporter errRpt) 
+                       throws WSDLException
+    {
+        fErrorReporter = errRpt;
+        init(ownerEl, attrValue);
+    }
+    
+    /* ************************************************************
+     *  XMLAttr interface declared methods 
+     * ************************************************************/
+
+    public void setErrorReporter(ErrorReporter errRpt) {
+        fErrorReporter = errRpt;
+    }
+    
+    public void init(Element ownerEl, String attrValue) throws WSDLException
+    {
+        fExternalForm = attrValue;
+        fContent = convert(ownerEl, attrValue);
+        if(fContent != null) fValid = true;
+    }
+    
+    public Object getContent() {
+        return fContent;
+    }
+    
+    public String toExternalForm() {
+        return fExternalForm;
+    }
+    
+    public boolean isValid() {
+        return fValid;
+    }
+    
+    /* ************************************************************
+     *  Non-API implementation methods 
+     * ************************************************************/
+
+    abstract protected Object convert(Element ownerEl, String attrValue) throws WSDLException;
+    
+    protected ErrorReporter getErrorReporter() throws WSDLException
+    {
+        if(fErrorReporter == null) {
+            fErrorReporter = new ErrorReporterImpl();
+        }
+        return fErrorReporter;
+    }
+    
+    /*
+     * Validity is initialized to false, but set to true during initialization
+     * if the attribute string format is valid (i.e. if it can be converted to
+     * an object of the appropriate type). This method may be used to change the
+     * validity later (e.g. if Validation determines an error).
+     * 
+     * TODO confirm this method is needed, otherwise remove it.
+     */
+    public void setValid(boolean validity) {
+        fValid = validity;
+    }
+}

Added: incubator/woden/java/src/org/apache/woden/xml/QNameAttr.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/xml/QNameAttr.java?rev=354068&view=auto
==============================================================================
--- incubator/woden/java/src/org/apache/woden/xml/QNameAttr.java (added)
+++ incubator/woden/java/src/org/apache/woden/xml/QNameAttr.java Mon Dec  5 05:33:56 2005
@@ -0,0 +1,28 @@
+/**
+ * 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:QName.
+ * 
+ * @author jkaputin@apache.org
+ */
+public interface QNameAttr extends XMLAttr 
+{
+    public QName getQName();
+}

Added: incubator/woden/java/src/org/apache/woden/xml/StringAttr.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/xml/StringAttr.java?rev=354068&view=auto
==============================================================================
--- incubator/woden/java/src/org/apache/woden/xml/StringAttr.java (added)
+++ incubator/woden/java/src/org/apache/woden/xml/StringAttr.java Mon Dec  5 05:33:56 2005
@@ -0,0 +1,27 @@
+/**
+ * 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;
+
+
+/**
+ * This interface represents XML attribute information items of type xs:string.
+ * 
+ * @author jkaputin@apache.org
+ */
+public interface StringAttr extends XMLAttr 
+{
+    public String getString();
+}

Added: incubator/woden/java/src/org/apache/woden/xml/URIAttr.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/xml/URIAttr.java?rev=354068&view=auto
==============================================================================
--- incubator/woden/java/src/org/apache/woden/xml/URIAttr.java (added)
+++ incubator/woden/java/src/org/apache/woden/xml/URIAttr.java Mon Dec  5 05:33:56 2005
@@ -0,0 +1,28 @@
+/**
+ * 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 java.net.URI;
+
+/**
+ * This interface represents XML attribute information items of type xs:anyURI.
+ * 
+ * @author jkaputin@apache.org
+ */
+public interface URIAttr extends XMLAttr 
+{
+    public URI getURI();
+}

Added: incubator/woden/java/src/org/apache/woden/xml/XMLAttr.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/xml/XMLAttr.java?rev=354068&view=auto
==============================================================================
--- incubator/woden/java/src/org/apache/woden/xml/XMLAttr.java (added)
+++ incubator/woden/java/src/org/apache/woden/xml/XMLAttr.java Mon Dec  5 05:33:56 2005
@@ -0,0 +1,44 @@
+/**
+ * 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 org.apache.woden.ErrorReporter;
+import org.apache.woden.WSDLException;
+import org.w3c.dom.Element;
+
+/**
+ * This interface represents XML attribute information items.
+ * 
+ * @author jkaputin@apache.org
+ */
+public interface XMLAttr 
+{
+    public void setErrorReporter(ErrorReporter errRpt);
+    
+    /**
+     * Take the external string form of the attribute and initialize 
+     * its internal object representation.
+     * 
+     * @throws WSDLException if conversion errors occur
+     */
+    public void init(Element ownerEl, String attrString) throws WSDLException;
+    
+    public Object getContent();
+    
+    public String toExternalForm();
+    
+    public boolean isValid();
+}



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