use of com.revolsys.gis.esri.gdb.file.capi.swig.Row in project com.revolsys.open by revolsys.
the class FileGdbQueryIterator method getNext.
@Override
protected synchronized Record getNext() throws NoSuchElementException {
final FileGdbRecordStore recordStore = this.recordStore;
final FileGdbEnumRowsIterator rows = this.rows;
if (rows == null || this.closed) {
throw new NoSuchElementException();
} else {
Row row = null;
while (this.offset > 0 && this.count < this.offset) {
row = rows.next();
this.count++;
if (this.closed) {
throw new NoSuchElementException();
}
}
if (this.count - this.offset >= this.limit) {
throw new NoSuchElementException();
}
row = rows.next();
this.count++;
try {
final Record record = this.recordFactory.newRecord(this.recordDefinition);
if (this.labelCountMap == null) {
recordStore.addStatistic("query", record);
} else {
this.labelCountMap.addCount(record);
}
record.setState(RecordState.INITIALIZING);
for (final FieldDefinition field : this.recordDefinition.getFields()) {
final String name = field.getName();
final AbstractFileGdbFieldDefinition esriFieldDefinition = (AbstractFileGdbFieldDefinition) field;
final Object value = esriFieldDefinition.getValue(row);
record.setValue(name, value);
if (this.closed) {
throw new NoSuchElementException();
}
}
record.setState(RecordState.PERSISTED);
if (this.closed) {
throw new NoSuchElementException();
}
return record;
} catch (final RuntimeException e) {
if (this.closed) {
throw new NoSuchElementException();
} else {
throw e;
}
} finally {
row.delete();
}
}
}
Aggregations