001    package railo.runtime.type.it;
002    
003    import java.util.Iterator;
004    import java.util.Map.Entry;
005    
006    import railo.runtime.engine.ThreadLocalPageContext;
007    import railo.runtime.type.Collection.Key;
008    import railo.runtime.type.KeyImpl;
009    import railo.runtime.type.Objects;
010    
011    public class ObjectsEntryIterator implements Iterator<Entry<Key, Object>> {
012    
013            private Iterator<Key> keys;
014            private Objects objs;
015    
016            public ObjectsEntryIterator(Key[] keys, Objects objs) {
017                    this.keys=new KeyIterator(keys);
018                    this.objs=objs;
019            }
020            public ObjectsEntryIterator(Iterator<Key> keys, Objects objs) {
021                    this.keys=keys;
022                    this.objs=objs;
023            }
024    
025            public boolean hasNext() {
026                    return keys.hasNext();
027            }
028    
029            @Override
030            public Entry<Key, Object> next() {
031                    Key key = KeyImpl.toKey(keys.next(),null);
032                    return new EntryImpl(objs,key);
033            }
034    
035            public void remove() {
036                    throw new UnsupportedOperationException("this operation is not suppored");
037            }
038    
039            public class EntryImpl implements Entry<Key, Object> {
040    
041                    protected Key key;
042                    private Objects  objcts;
043    
044                    public EntryImpl(Objects objcts,Key key) {
045                            this.key=key;
046                            this. objcts= objcts;
047                    }
048    
049                    @Override
050                    public Key getKey() {
051                            return key;
052                    }
053    
054                    @Override
055                    public Object getValue() {
056                            return objcts.get(ThreadLocalPageContext.get(),key,null);
057                    }
058    
059                    @Override
060                    public Object setValue(Object value) {
061                            return objcts.setEL(ThreadLocalPageContext.get(),key,value);
062                    }
063    
064            }
065    }