Author: veithen
Date: Sat Aug 15 13:06:10 2009
New Revision: 804470

URL: http://svn.apache.org/viewvc?rev=804470&view=rev
Log:
Added a getXMLStreamReader method to OMElement that takes a boolean argument to 
enable or disable caching.

Modified:
    
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java?rev=804470&r1=804469&r2=804470&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
 Sat Aug 15 13:06:10 2009
@@ -246,23 +246,31 @@
 
 
     /**
-     * Returns the pull parser that will generate the pull events relevant to 
THIS element.
-     * <p/>
-     * <p>Caching is on.</p>
-     *
-     * @return Returns an XMLStreamReader relative to this element.
+     * Get a pull parser representation of this element with caching enabled. 
This method has the
+     * same effect as {...@link #getXMLStreamReader(boolean)} with 
<code>cache</code> set to
+     * <code>true</code>.
+     * 
+     * @return an {...@link XMLStreamReader} representation of this element
      */
     XMLStreamReader getXMLStreamReader();
 
     /**
-     * Returns the pull parser that will generate the pull events relevant to 
THIS element.
-     * <p/>
-     * <p>Caching is off.</p>
-     *
-     * @return Returns an XMLStreamReader relative to this element, with no 
caching.
+     * Get a pull parser representation of this element with caching disabled. 
This method has the
+     * same effect as {...@link #getXMLStreamReader(boolean)} with 
<code>cache</code> set to
+     * <code>false</code>.
+     * 
+     * @return an {...@link XMLStreamReader} representation of this element
      */
     XMLStreamReader getXMLStreamReaderWithoutCaching();
 
+    /**
+     * Get a pull parser representation of this element.
+     *
+     * @param cache indicates if caching should be enabled
+     * @return an {...@link XMLStreamReader} representation of this element
+     */
+    XMLStreamReader getXMLStreamReader(boolean cache);
+
     /** @param text  */
     void setText(String text);
 

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java?rev=804470&r1=804469&r2=804470&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
 Sat Aug 15 13:06:10 2009
@@ -1160,7 +1160,7 @@
      *
      * @return Returns reader.
      */
-    private XMLStreamReader getXMLStreamReader(boolean cache) {
+    public XMLStreamReader getXMLStreamReader(boolean cache) {
         if ((builder == null) && !cache) {
             throw new UnsupportedOperationException(
                     "This element was not created in a manner to be switched");

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java?rev=804470&r1=804469&r2=804470&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
 Sat Aug 15 13:06:10 2009
@@ -770,7 +770,7 @@
      *
      * @return Returns reader.
      */
-    private XMLStreamReader getXMLStreamReader(boolean cache) {
+    public XMLStreamReader getXMLStreamReader(boolean cache) {
         if (builder != null && this.builder instanceof StAXOMBuilder) {
             if (!isComplete()) {
                 if (((StAXOMBuilder) builder).isLookahead()) {

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java?rev=804470&r1=804469&r2=804470&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
 Sat Aug 15 13:06:10 2009
@@ -483,17 +483,15 @@
         return super.getFirstElement();
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.axiom.om.OMElement#getXMLStreamReader()
-     */
-    public XMLStreamReader getXMLStreamReader() {
+    public XMLStreamReader getXMLStreamReader(boolean cache) {
         if (isDebugEnabled) {
-            log.debug("getting XMLStreamReader for " + getPrintableName());
+            log.debug("getting XMLStreamReader for " + getPrintableName()
+                    + " with cache=" + cache);
         }
         if (isExpanded) {
-            return super.getXMLStreamReader();
+            return super.getXMLStreamReader(cache);
         } else {
-            if (isDestructiveRead()) {
+            if (cache && isDestructiveRead()) {
                 forceExpand();
                 return super.getXMLStreamReader();
             }
@@ -501,20 +499,12 @@
         }
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.axiom.om.OMElement#getXMLStreamReaderWithoutCaching()
-     */
+    public XMLStreamReader getXMLStreamReader() {
+        return getXMLStreamReader(true);
+    }
+
     public XMLStreamReader getXMLStreamReaderWithoutCaching() {
-        if (isDebugEnabled) {
-            log.debug("getting XMLStreamReader without caching for " +
-                    getPrintableName());
-        }
-        if (isExpanded) {         
-            XMLStreamReader reader = super.getXMLStreamReaderWithoutCaching();
-            return reader;
-        } else {
-            return getDirectReader();
-        }
+        return getXMLStreamReader(false);
     }
 
     /* (non-Javadoc)


Reply via email to