001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.runtime.type.it; 020 021import java.util.Iterator; 022import java.util.Map.Entry; 023 024import lucee.runtime.engine.ThreadLocalPageContext; 025import lucee.runtime.type.Collection.Key; 026import lucee.runtime.type.KeyImpl; 027import lucee.runtime.type.Objects; 028 029public class ObjectsEntryIterator implements Iterator<Entry<Key, Object>> { 030 031 private Iterator<Key> keys; 032 private Objects objs; 033 034 public ObjectsEntryIterator(Key[] keys, Objects objs) { 035 this.keys=new KeyIterator(keys); 036 this.objs=objs; 037 } 038 public ObjectsEntryIterator(Iterator<Key> keys, Objects objs) { 039 this.keys=keys; 040 this.objs=objs; 041 } 042 043 public boolean hasNext() { 044 return keys.hasNext(); 045 } 046 047 @Override 048 public Entry<Key, Object> next() { 049 Key key = KeyImpl.toKey(keys.next(),null); 050 return new EntryImpl(objs,key); 051 } 052 053 public void remove() { 054 throw new UnsupportedOperationException("this operation is not suppored"); 055 } 056 057 public class EntryImpl implements Entry<Key, Object> { 058 059 protected Key key; 060 private Objects objcts; 061 062 public EntryImpl(Objects objcts,Key key) { 063 this.key=key; 064 this. objcts= objcts; 065 } 066 067 @Override 068 public Key getKey() { 069 return key; 070 } 071 072 @Override 073 public Object getValue() { 074 return objcts.get(ThreadLocalPageContext.get(),key,null); 075 } 076 077 @Override 078 public Object setValue(Object value) { 079 return objcts.setEL(ThreadLocalPageContext.get(),key,value); 080 } 081 082 } 083}