1 17 package org.alfresco.jcr.util; 18 19 import java.util.NoSuchElementException ; 20 21 import javax.jcr.RangeIterator; 22 23 24 29 public abstract class AbstractRangeIterator implements RangeIterator 30 { 31 private int position = -1; 32 33 39 public AbstractRangeIterator() 40 { 41 } 42 43 48 protected long skip() 49 { 50 skip(1); 51 return position; 52 } 53 54 57 public void skip(long skipNum) 58 { 59 if (skipNum < 0) 60 { 61 throw new IllegalArgumentException ("skipNum must be positive."); 62 } 63 if (position + skipNum >= getSize()) 64 { 65 throw new NoSuchElementException ("Cannot skip " + skipNum + " elements from position " + getPosition() + " as only " + getSize() + " elements are available."); 66 } 67 position += skipNum; 68 } 69 70 73 public long getPosition() 74 { 75 return position + 1; 76 } 77 78 81 public boolean hasNext() 82 { 83 return getPosition() < getSize(); 84 } 85 86 89 public void remove() 90 { 91 throw new UnsupportedOperationException (); 92 } 93 94 } 95 | Popular Tags |