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    public class ValueIterator implements Iterator<Object>, Enumeration<Object> {
010            
011            
012    
013            private Collection coll;
014            protected Key[] keys;
015            protected int pos;
016    
017            public ValueIterator(Collection coll, Collection.Key[] keys){
018                    this.coll=coll;
019                    this.keys=keys;
020            }
021            
022            @Override
023            public boolean hasNext() {
024                    return (keys.length)>pos;
025            }
026    
027            @Override
028            public Object next() {
029                    Key key = keys[pos++];
030                    if(key==null) return null;
031                    return coll.get(key,null);
032            }
033    
034            @Override
035            public boolean hasMoreElements() {
036                    return hasNext();
037            }
038    
039            @Override
040            public Object nextElement() {
041                    return next();
042            }
043    
044            @Override
045            public void remove() {
046                    throw new UnsupportedOperationException("this operation is not suppored");
047            }
048    }