You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by wo...@apache.org on 2008/04/23 22:59:41 UTC

svn commit: r651062 - in /webservices/commons/trunk/modules/axiom/modules: axiom-api/src/main/java/org/apache/axiom/om/ axiom-api/src/main/java/org/apache/axiom/om/xpath/ axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ axiom-impl/src/main/java/or...

Author: woodroy
Date: Wed Apr 23 13:59:37 2008
New Revision: 651062

URL: http://svn.apache.org/viewvc?rev=651062&view=rev
Log:
WSCOMMONS-326
Contributor: Roy Wood
Implement OMStAXWrapper.getAttributeType(...) correctly

Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMAttribute.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMConstants.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/xpath/DocumentNavigator.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMStAXWrapper.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMStAXWrapper.java
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMAttributeTest.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMAttribute.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMAttribute.java?rev=651062&r1=651061&r2=651062&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMAttribute.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMAttribute.java Wed Apr 23 13:59:37 2008
@@ -35,6 +35,12 @@
     /** @param value  */
     void setAttributeValue(String value);
 
+    /** @return Returns String. */
+    String getAttributeType();
+
+    /** @param value  */
+    void setAttributeType(String value);
+
     /** @param omNamespace  */
     void setOMNamespace(OMNamespace omNamespace);
 

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMConstants.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMConstants.java?rev=651062&r1=651061&r2=651062&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMConstants.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMConstants.java Wed Apr 23 13:59:37 2008
@@ -67,5 +67,15 @@
 
     /** No its not a mistake. This is the default nsURI of the default namespace of a node */
     static final String DEFAULT_DEFAULT_NAMESPACE = "\"\"";
+    
+	static final String XMLATTRTYPE_CDATA = "CDATA";
+	static final String XMLATTRTYPE_ID = "ID";
+	static final String XMLATTRTYPE_IDREF = "IDREF"; 
+	static final String XMLATTRTYPE_IDREFS = "IDREFS"; 
+	static final String XMLATTRTYPE_NMTOKEN = "NMTOKEN"; 
+	static final String XMLATTRTYPE_NMTOKENS = "NMTOKENS"; 
+	static final String XMLATTRTYPE_ENTITY = "ENTITY"; 
+	static final String XMLATTRTYPE_ENTITIES = "ENTITIES";  
+	static final String XMLATTRTYPE_NOTATION = "NOTATION"; 
 
 }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/xpath/DocumentNavigator.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/xpath/DocumentNavigator.java?rev=651062&r1=651061&r2=651062&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/xpath/DocumentNavigator.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/xpath/DocumentNavigator.java Wed Apr 23 13:59:37 2008
@@ -739,8 +739,16 @@
             return attribute.getAttributeValue();
         }
 
+        public String getAttributeType() {
+            return attribute.getAttributeType();
+        }
+
         public void setAttributeValue(String value) {
             attribute.setAttributeValue(value);
+        }
+
+        public void setAttributeType(String type) {
+            attribute.setAttributeType(type);
         }
 
         public void setOMNamespace(OMNamespace omNamespace) {

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java?rev=651062&r1=651061&r2=651062&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java Wed Apr 23 13:59:37 2008
@@ -40,6 +40,9 @@
     /** Attribute value */
     private TextImpl attrValue;
 
+    /** Attribute type */
+    private String attrType;
+
     /** Attribute namespace */
     private NamespaceImpl namespace;
 
@@ -61,6 +64,7 @@
         super(ownerDocument, factory);
         this.attrName = localName;
         this.attrValue = new TextImpl(ownerDocument, value, factory);
+        this.attrType = OMConstants.XMLATTRTYPE_CDATA;
         this.namespace = (NamespaceImpl) ns;
     }
 
@@ -69,6 +73,7 @@
         super(ownerDocument, factory);
         this.attrName = name;
         this.attrValue = new TextImpl(ownerDocument, value, factory);
+        this.attrType = OMConstants.XMLATTRTYPE_CDATA;
     }
 
     public AttrImpl(DocumentImpl ownerDocument, String name, OMFactory factory) {
@@ -79,6 +84,7 @@
             this.namespace = new NamespaceImpl(
                     OMConstants.XMLNS_NS_URI, OMConstants.XMLNS_NS_PREFIX);
         }
+        this.attrType = OMConstants.XMLATTRTYPE_CDATA;
     }
 
     public AttrImpl(DocumentImpl ownerDocument, String localName,
@@ -86,6 +92,7 @@
         super(ownerDocument, factory);
         this.attrName = localName;
         this.namespace = (NamespaceImpl) namespace;
+        this.attrType = OMConstants.XMLATTRTYPE_CDATA;
     }
 
     // /
@@ -248,6 +255,15 @@
     }
 
     /**
+     * Returns the attribute value.
+     *
+     * @see org.apache.axiom.om.OMAttribute#getAttributeType()
+     */
+    public String getAttributeType() {
+        return this.attrType;
+    }
+
+    /**
      * Sets the name of attribute.
      *
      * @see org.apache.axiom.om.OMAttribute#setLocalName(String)
@@ -280,6 +296,15 @@
         }
         this.attrValue = (TextImpl) this.getOwnerDocument().createTextNode(
                 value);
+    }
+
+    /**
+     * Sets the attribute value.
+     *
+     * @see org.apache.axiom.om.OMAttribute#setAttributeType(String)
+     */
+    public void setAttributeType(String attrType) {    
+    	this.attrType = attrType;
     }
 
     /**

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMStAXWrapper.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMStAXWrapper.java?rev=651062&r1=651061&r2=651062&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMStAXWrapper.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMStAXWrapper.java Wed Apr 23 13:59:37 2008
@@ -487,8 +487,11 @@
             returnString = parser.getAttributeType(i);
         } else {
             if (isStartElement() || (currentEvent == ATTRIBUTE)) {
+               	OMAttribute attrib = getAttribute((OMElement) lastNode, i);
+                if (attrib != null) {
+                    returnString = attrib.getAttributeType();
+                }
 
-                // todo implement this
             } else {
                 throw new IllegalStateException(
                         "attribute type accessed in illegal event!");

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java?rev=651062&r1=651061&r2=651062&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java Wed Apr 23 13:59:37 2008
@@ -20,6 +20,7 @@
 package org.apache.axiom.om.impl.llom;
 
 import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMConstants;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMElement;
@@ -34,6 +35,9 @@
     /** Field value */
     private String value;
 
+    /** Field type */
+    private String type;
+
     /** Field namespace */
     private OMNamespace namespace;
 
@@ -58,6 +62,7 @@
         this.localName = localName;
         this.value = value;
         this.namespace = ns;
+        this.type = OMConstants.XMLATTRTYPE_CDATA;
         this.factory = factory;
     }
 
@@ -113,6 +118,24 @@
      */
     public void setAttributeValue(String value) {
         this.value = value;
+    }
+
+    /**
+     * Method getAttributeType.
+     *
+     * @return Returns type.
+     */
+    public String getAttributeType() {
+    	return type;
+    }
+
+    /**
+     * Method setAttributeType.
+     *
+     * @param type
+     */
+    public void setAttributeType(String type) {
+        this.type = type;
     }
 
     /**

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMStAXWrapper.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMStAXWrapper.java?rev=651062&r1=651061&r2=651062&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMStAXWrapper.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMStAXWrapper.java Wed Apr 23 13:59:37 2008
@@ -569,13 +569,18 @@
             returnString = parser.getAttributeType(i);
         } else {
             if (isStartElement() || (currentEvent == ATTRIBUTE)) {
+                
+            	OMAttribute attrib = getAttribute((OMElement) lastNode, i);
+                if (attrib != null) {
+                    returnString = attrib.getAttributeType();
+                }
 
-                // todo implement this
             } else {
                 throw new IllegalStateException(
                         "attribute type accessed in illegal event!");
             }
         }
+        
         return returnString;
     }
 

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMAttributeTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMAttributeTest.java?rev=651062&r1=651061&r2=651062&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMAttributeTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/llom/OMAttributeTest.java Wed Apr 23 13:59:37 2008
@@ -22,6 +22,7 @@
 import junit.framework.TestCase;
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMConstants;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNamespace;
@@ -68,6 +69,14 @@
                 "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header name = \"jhon\"/><soapenv:Body><my:uploadFileUsingMTOM xmlns:my=\"http://localhost/my\"><my:folderName>/home/saliya/Desktop</my:folderName></my:uploadFileUsingMTOM></soapenv:Body><Body>TTTT</Body> </soapenv:Envelope>";
 
         assertEquals(addAttributeMethod1(xmlString), addAttributeMethod2(xmlString));
+    }
+
+    public void testDefaultAttributeType() throws Exception {
+        OMFactory factory = OMAbstractFactory.getOMFactory();
+        OMNamespace ns = factory.createOMNamespace("http://www.me.com", "axiom");
+        OMAttribute at = factory.createOMAttribute("id", ns, "value");
+
+        assertEquals(at.getAttributeType(), "CDATA");
     }
 
     private String addAttributeMethod1(String xmlString) throws Exception {