001    package railo.runtime.util;
002    
003    import java.util.Iterator;
004    
005    /**
006     * Iterator Implementation for a Object Array
007     */
008    public final class ArrayIterator implements Iterator {
009            
010            private Object[] arr;
011            private int offset;
012            private int length;
013    
014            /**
015             * constructor for the class
016             * @param arr Base Array
017             */
018            public ArrayIterator(Object[] arr) {
019                    this.arr=arr;
020                    this.offset=0;
021                    this.length=arr.length;
022            }
023    
024            public ArrayIterator(Object[] arr, int offset, int length) {
025                    this.arr=arr;
026                    this.offset=offset;
027                    this.length=offset+length;
028                    if(this.length>arr.length)this.length=arr.length;
029                    
030            }
031    
032            public ArrayIterator(Object[] arr, int offset) {
033                    this.arr=arr;
034                    this.offset=offset;
035                    this.length=arr.length;
036                    
037            }
038    
039            @Override
040            public void remove() {
041                    throw new UnsupportedOperationException("this operation is not suppored");
042            }
043    
044            @Override
045            public boolean hasNext() {
046                    return (length)>offset;
047            }
048    
049            @Override
050            public Object next() {
051                    return arr[offset++];
052            }
053            
054    }