001 package railo.runtime.com; 002 003 import java.util.Iterator; 004 005 import railo.runtime.exp.CasterException; 006 import railo.runtime.exp.PageRuntimeException; 007 import railo.runtime.op.Caster; 008 import railo.runtime.type.Collection; 009 010 import com.jacob.com.EnumVariant; 011 012 /** 013 * MUST this is a value iterator instead of a key iterator 014 * 015 */ 016 public final class COMKeyWrapperIterator implements Iterator<Collection.Key> { 017 018 private EnumVariant enumVariant; 019 private COMObject wrapper; 020 021 /** 022 * @param wrapper 023 */ 024 public COMKeyWrapperIterator(COMObject wrapper) { 025 this.enumVariant=new EnumVariant(wrapper.getDispatch()); 026 this.wrapper=wrapper; 027 } 028 029 @Override 030 public void remove() { 031 enumVariant.safeRelease(); 032 } 033 034 @Override 035 public boolean hasNext() { 036 return enumVariant.hasMoreElements(); 037 } 038 039 @Override 040 public Collection.Key next() { 041 try { 042 return Caster.toKey(COMUtil.toObject(wrapper,enumVariant.Next(),"",null)); 043 } catch (CasterException e) { 044 throw new PageRuntimeException(e); 045 } 046 } 047 }