You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2009/05/18 21:15:08 UTC

svn commit: r776059 - /xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSModelImpl.java

Author: mrglavas
Date: Mon May 18 19:15:08 2009
New Revision: 776059

URL: http://svn.apache.org/viewvc?rev=776059&view=rev
Log:
Adding a native implementation of Iterator for the XSNamespaceItemList.

Modified:
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSModelImpl.java

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSModelImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSModelImpl.java?rev=776059&r1=776058&r2=776059&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSModelImpl.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSModelImpl.java Mon May 18 19:15:08 2009
@@ -18,6 +18,9 @@
 package org.apache.xerces.impl.xs;
 
 import java.util.AbstractList;
+import java.util.Iterator;
+import java.util.ListIterator;
+import java.util.NoSuchElementException;
 import java.util.Vector;
 
 import org.apache.xerces.impl.Constants;
@@ -567,5 +570,64 @@
     public int size() {
         return getLength();
     }
+    
+    public Iterator iterator() {
+        return listIterator0(0);
+    }
+    
+    public ListIterator listIterator() {
+        return listIterator0(0);
+    }
+    
+    public ListIterator listIterator(int index) {
+        if (index >= 0 && index < fGrammarCount) {
+            return listIterator0(index);
+        }
+        throw new IndexOutOfBoundsException("Index: " + index);
+    }
+    
+    private ListIterator listIterator0(int index) {
+        return new XSNamespaceItemListIterator(index);
+    }
+    
+    private final class XSNamespaceItemListIterator implements ListIterator {
+        private int index;
+        public XSNamespaceItemListIterator(int index) {
+            this.index = index;
+        }
+        public boolean hasNext() {
+            return (index < fGrammarCount);
+        }
+        public Object next() {
+            if (index < fGrammarCount) {
+                return fGrammarList[index++];
+            }
+            throw new NoSuchElementException();
+        }
+        public boolean hasPrevious() {
+            return (index > 0);
+        }
+        public Object previous() {
+            if (index > 0) {
+                return fGrammarList[--index];
+            }
+            throw new NoSuchElementException();
+        }
+        public int nextIndex() {
+            return index;
+        }
+        public int previousIndex() {
+            return index - 1;
+        }
+        public void remove() {
+            throw new UnsupportedOperationException();
+        }
+        public void set(Object o) {
+            throw new UnsupportedOperationException();
+        }
+        public void add(Object o) {
+            throw new UnsupportedOperationException();
+        }
+    }
 
 } // class XSModelImpl



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org