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 008 /** 009 * Iterator Implementation for a Object Array 010 */ 011 public final class StringIterator implements Iterator<String>,Enumeration<String> { 012 013 private Collection.Key[] arr; 014 private int pos; 015 016 /** 017 * constructor for the class 018 * @param arr Base Array 019 */ 020 public StringIterator(Collection.Key[] arr) { 021 this.arr=arr; 022 this.pos=0; 023 } 024 025 @Override 026 public void remove() { 027 throw new UnsupportedOperationException("this operation is not suppored"); 028 } 029 030 @Override 031 public boolean hasNext() { 032 return (arr.length)>pos; 033 } 034 035 @Override 036 public String next() { 037 Collection.Key key = arr[pos++]; 038 if(key==null) return null; 039 return key.getString(); 040 } 041 042 public boolean hasMoreElements() { 043 return hasNext(); 044 } 045 046 public String nextElement() { 047 return next(); 048 } 049 }