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            /**
040             * @see java.util.Iterator#remove()
041             */
042            public void remove() {
043                    throw new UnsupportedOperationException("this operation is not suppored");
044            }
045    
046            /**
047             * @see java.util.Iterator#hasNext()
048             */
049            public boolean hasNext() {
050                    return (length)>offset;
051            }
052    
053            /**
054             * @see java.util.Iterator#next()
055             */
056            public Object next() {
057                    return arr[offset++];
058            }
059            
060    }