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 ve...@apache.org on 2009/05/19 20:17:02 UTC

svn commit: r776400 - in /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom: om/impl/OMStAXWrapper.java stax/AbstractXMLStreamReader.java

Author: veithen
Date: Tue May 19 18:17:02 2009
New Revision: 776400

URL: http://svn.apache.org/viewvc?rev=776400&view=rev
Log:
Moved some of the reusable code from OMStAXWrapper to a new class AbstractXMLStreamReader (to be completed later).

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/stax/AbstractXMLStreamReader.java   (with props)
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMStAXWrapper.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMStAXWrapper.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMStAXWrapper.java?rev=776400&r1=776399&r2=776400&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMStAXWrapper.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMStAXWrapper.java Tue May 19 18:17:02 2009
@@ -53,6 +53,7 @@
 import org.apache.axiom.om.impl.builder.StAXBuilder;
 import org.apache.axiom.om.impl.exception.OMStreamingException;
 import org.apache.axiom.om.impl.util.NamespaceContextImpl;
+import org.apache.axiom.stax.AbstractXMLStreamReader;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -60,7 +61,7 @@
  * Note - This class also implements the streaming constants interface to get access to the StAX
  * constants.
  */
-public class OMStAXWrapper 
+public class OMStAXWrapper extends AbstractXMLStreamReader
     implements OMXMLStreamReader, XMLStreamConstants {
     
     private static final Log log = LogFactory.getLog(OMStAXWrapper.class);
@@ -352,17 +353,6 @@
     }
 
     /**
-     * @return Returns boolean.
-     * @see javax.xml.stream.XMLStreamReader#hasText()
-     */
-    public boolean hasText() {
-        return ((currentEvent == CHARACTERS) || (currentEvent == DTD)
-                || (currentEvent == CDATA)
-                || (currentEvent == ENTITY_REFERENCE)
-                || (currentEvent == COMMENT) || (currentEvent == SPACE));
-    }
-
-    /**
      * @return Returns int.
      * @see javax.xml.stream.XMLStreamReader#getTextLength()
      */
@@ -811,17 +801,6 @@
     }
 
     /**
-     * @param i
-     * @param s
-     * @param s1
-     * @throws XMLStreamException
-     * @see javax.xml.stream.XMLStreamReader#require(int, String, String)
-     */
-    public void require(int i, String s, String s1) throws XMLStreamException {
-        throw new XMLStreamException();
-    }
-
-    /**
      * Method isStartElement.
      *
      * @return Returns boolean.
@@ -905,30 +884,6 @@
     }
 
     /**
-     * Returns the next tag.
-     *
-     * @return Returns int.
-     * @throws org.apache.axiom.om.impl.exception.OMStreamingException
-     *
-     * @throws XMLStreamException
-     */
-    public int nextTag() throws XMLStreamException {
-        int eventType = next();
-        while ((eventType == XMLStreamConstants.CHARACTERS && isWhiteSpace()) // skip whitespace
-                || (eventType == XMLStreamConstants.CDATA && isWhiteSpace()) // skip whitespace
-                || eventType == XMLStreamConstants.SPACE
-                || eventType == XMLStreamConstants.PROCESSING_INSTRUCTION
-                || eventType == XMLStreamConstants.COMMENT) {
-            eventType = next();
-        }
-        if (eventType != XMLStreamConstants.START_ELEMENT &&
-                eventType != XMLStreamConstants.END_ELEMENT) {
-            throw new XMLStreamException("expected start or end tag", getLocation());
-        }
-        return eventType;
-    }
-
-    /**
      * @return Returns String.
      * @throws XMLStreamException
      * @see javax.xml.stream.XMLStreamReader#getElementText()

Added: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/stax/AbstractXMLStreamReader.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/stax/AbstractXMLStreamReader.java?rev=776400&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/stax/AbstractXMLStreamReader.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/stax/AbstractXMLStreamReader.java Tue May 19 18:17:02 2009
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.stax;
+
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * Partial implementation of the {@link XMLStreamReader} interface.
+ * This class implements methods that can be easily expressed in terms of other
+ * (abstract) methods or for which it makes sense to provide a default
+ * implementation.
+ */
+public abstract class AbstractXMLStreamReader implements XMLStreamReader {
+    /**
+     * @return Returns boolean.
+     * @see javax.xml.stream.XMLStreamReader#hasText()
+     */
+    public boolean hasText() {
+        int event = getEventType();
+        return ((event == CHARACTERS) || (event == DTD)
+                || (event == CDATA)
+                || (event == ENTITY_REFERENCE)
+                || (event == COMMENT) || (event == SPACE));
+    }
+
+    /**
+     * Returns the next tag.
+     *
+     * @return Returns int.
+     * @throws org.apache.axiom.om.impl.exception.OMStreamingException
+     *
+     * @throws XMLStreamException
+     */
+    public int nextTag() throws XMLStreamException {
+        int eventType = next();
+        while ((eventType == XMLStreamConstants.CHARACTERS && isWhiteSpace()) // skip whitespace
+                || (eventType == XMLStreamConstants.CDATA && isWhiteSpace()) // skip whitespace
+                || eventType == XMLStreamConstants.SPACE
+                || eventType == XMLStreamConstants.PROCESSING_INSTRUCTION
+                || eventType == XMLStreamConstants.COMMENT) {
+            eventType = next();
+        }
+        if (eventType != XMLStreamConstants.START_ELEMENT &&
+                eventType != XMLStreamConstants.END_ELEMENT) {
+            throw new XMLStreamException("expected start or end tag", getLocation());
+        }
+        return eventType;
+    }
+
+    /**
+     * @param i
+     * @param s
+     * @param s1
+     * @throws XMLStreamException
+     * @see javax.xml.stream.XMLStreamReader#require(int, String, String)
+     */
+    // TODO: this comes from OMStAXWrapper and needs to be implemented properly
+    public void require(int i, String s, String s1) throws XMLStreamException {
+        throw new XMLStreamException();
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/stax/AbstractXMLStreamReader.java
------------------------------------------------------------------------------
    svn:eol-style = native