You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by as...@apache.org on 2004/10/11 09:15:37 UTC

svn commit: rev 54512 - webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/src/java/org/apache/axis/om/impl/util

Author: aslom
Date: Mon Oct 11 00:15:34 2004
New Revision: 54512

Added:
   webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/src/java/org/apache/axis/om/impl/util/
   webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/src/java/org/apache/axis/om/impl/util/OMChildrenIterator.java
Log:
applied Eran Chinthaka patch

Added: webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/src/java/org/apache/axis/om/impl/util/OMChildrenIterator.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/chinthaka/OMAPI_with_Impl/src/java/org/apache/axis/om/impl/util/OMChildrenIterator.java	Mon Oct 11 00:15:34 2004
@@ -0,0 +1,81 @@
+package org.apache.axis.om.impl.util;
+
+import org.apache.axis.om.OMNode;
+
+import java.util.Iterator;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ * <p/>
+ * User: Eran Chinthaka - Lanka Software Foundation
+ * Date: Oct 11, 2004
+ * Time: 11:23:07 AM
+ */
+public class OMChildrenIterator implements Iterator {
+
+    private OMNode currentChild;
+
+    public OMChildrenIterator(OMNode currentChild) {
+        this.currentChild = currentChild;
+    }
+
+    /**
+     * Removes from the underlying collection the last element returned by the
+     * iterator (optional operation).  This method can be called only once per
+     * call to <tt>next</tt>.  The behavior of an iterator is unspecified if
+     * the underlying collection is modified while the iteration is in
+     * progress in any way other than by calling this method.
+     *
+     * @throws UnsupportedOperationException if the <tt>remove</tt>
+     *                                       operation is not supported by this Iterator.
+     * @throws IllegalStateException         if the <tt>next</tt> method has not
+     *                                       yet been called, or the <tt>remove</tt> method has already
+     *                                       been called after the last call to the <tt>next</tt>
+     *                                       method.
+     */
+    public void remove() {
+        OMNode temp = currentChild.getNextSibling();
+        currentChild.detach();
+        currentChild = temp;
+    }
+
+    /**
+     * Returns <tt>true</tt> if the iteration has more elements. (In other
+     * words, returns <tt>true</tt> if <tt>next</tt> would return an element
+     * rather than throwing an exception.)
+     *
+     * @return <tt>true</tt> if the iterator has more elements.
+     */
+    public boolean hasNext() {
+        return (currentChild == null || currentChild.getNextSibling() == null);
+    }
+
+    /**
+     * Returns the next element in the iteration.
+     *
+     * @return the next element in the iteration.
+     * @throws java.util.NoSuchElementException
+     *          iteration has no more elements.
+     */
+    public Object next() {
+
+        if (hasNext()) {
+            currentChild = currentChild.getNextSibling();
+            return currentChild;
+        }
+        return null;
+
+    }
+}