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,Enumeration {
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;
024                    this.pos=0;
025            }
026    
027            /**
028             * @see java.util.Iterator#remove()
029             */
030            public void remove() {
031                    throw new UnsupportedOperationException("this operation is not suppored");
032            }
033    
034            /**
035             * @see java.util.Iterator#hasNext()
036             */
037            public boolean hasNext() {
038                    return (arr.length)>pos;
039            }
040    
041            /**
042             * @see java.util.Iterator#next()
043             */
044            public Object next() {
045                    Key key = arr[pos++];
046                    if(key==null) return null;
047                    return key.getString();
048            }
049    
050            public boolean hasMoreElements() {
051                    return hasNext();
052            }
053    
054            public Object nextElement() {
055                    return next();
056            }
057    }