Revision 26028 branches/v2_0_0_prep/libraries/libFMap_dalfile/src/org/gvsig/fmap/dal/store/dbf/DBFSetProvider.java

View differences:

DBFSetProvider.java
4 4
package org.gvsig.fmap.dal.store.dbf;
5 5

  
6 6
import java.util.Iterator;
7
import java.util.NoSuchElementException;
7 8

  
8 9
import org.gvsig.fmap.dal.exception.DataException;
9 10
import org.gvsig.fmap.dal.exception.ReadRuntimeException;
......
79 80
	/* (non-Javadoc)
80 81
	 * @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#iterator()
81 82
	 */
82
	public Iterator iterator() {
83
	public Iterator iterator() throws DataException {
83 84
		return this.iterator(0);
84 85
	}
85 86

  
86 87
	/* (non-Javadoc)
87 88
	 * @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#iterator(long)
88 89
	 */
89
	public Iterator iterator(long index) {
90
	public Iterator iterator(long index) throws DataException {
90 91
		return new DBFIterartor(this.store, this.query.getFeatureType(), index);
91 92
	}
92 93

  
......
94 95
		protected long index;
95 96
		protected DBFStoreProvider store;
96 97
		protected FeatureType type;
98
		protected long count;
97 99

  
98 100
		public DBFIterartor(DBFStoreProvider store, FeatureType type,
99
				long startOn) {
101
				long startOn) throws DataException {
100 102
			this.store = store;
101 103
			this.index = startOn;
102 104
			this.type = type;
105
			this.count = this.store.getFeatureCount();
103 106
		}
104 107

  
105 108
		public boolean hasNext() {
106
			try {
107
				return this.store.getFeatureCount() > index;
108
			} catch (DataException e) {
109
				throw new ReadRuntimeException("hasNext", e);
110
			}
109
			return this.count > index;
111 110
		}
112 111

  
113 112
		public Object next() {
113
			if (index >= this.count) {
114
				throw new NoSuchElementException();
115
			}
114 116
			try {
117

  
115 118
				FeatureData ret = this.store.getFeatureDataByIndex(index,
116 119
						this.type);
117 120
				index++;
......
136 139
		}
137 140

  
138 141
		public Object next() {
142
			if (index >= this.count) {
143
				throw new NoSuchElementException();
144
			}
145

  
139 146
			try {
140 147
				this.store.initFeatureDataByIndex(this.data, index, type);
141 148
			} catch (DataException e) {

Also available in: Unified diff