001    package railo.runtime.type.it;
002    
003    import java.util.Enumeration;
004    import java.util.Iterator;
005    
006    import railo.runtime.type.Collection;
007    import railo.runtime.type.Collection.Key;
008    
009    /**
010     * Iterator Implementation for a Object Array
011     */
012    public final class KeyIterator implements Iterator<Collection.Key>,Enumeration<Collection.Key> {
013            
014            private Collection.Key[] arr;
015            private int pos;
016    
017            /**
018             * constructor for the class
019             * @param arr Base Array
020             */
021            public KeyIterator(Collection.Key[] arr) {
022                    
023                    this.arr=arr==null?new Collection.Key[0]:arr;
024                    this.pos=0;
025            }
026    
027            @Override
028            public void remove() {
029                    throw new UnsupportedOperationException("this operation is not suppored");
030            }
031    
032            @Override
033            public boolean hasNext() {
034                    return (arr.length)>pos;
035            }
036    
037            @Override
038            public Collection.Key next() {
039                    Key key = arr[pos++];
040                    if(key==null) return null;
041                    return key;
042            }
043    
044            public boolean hasMoreElements() {
045                    return hasNext();
046            }
047    
048            public Collection.Key nextElement() {
049                    return next();
050            }
051    }