3 import java.util.Iterator;
4 import java.util.NoSuchElementException;
5 import org.yaz4j.exception.ZoomException;
6 import org.yaz4j.jni.SWIGTYPE_p_ZOOM_scanset_p;
7 import org.yaz4j.jni.SWIGTYPE_p_size_t;
8 import org.yaz4j.jni.yaz4jlib;
10 public class ScanSet implements Iterable<ScanTerm> {
13 private Connection conn;
14 private SWIGTYPE_p_ZOOM_scanset_p scanSet;
15 private boolean disposed = false;
16 private long size = 0;
18 ScanSet(SWIGTYPE_p_ZOOM_scanset_p scanSet, Connection conn) {
19 this.scanSet = scanSet;
20 size = yaz4jlib.ZOOM_scanset_size(scanSet);
24 public void finalize() {
28 public ScanTerm get(long index) {
29 SWIGTYPE_p_size_t occ = yaz4jlib.new_size_tp();
30 SWIGTYPE_p_size_t length = yaz4jlib.new_size_tp();
31 String term = yaz4jlib.ZOOM_scanset_term(scanSet, (long) index, occ, length);
32 long occurences = yaz4jlib.size_tp_value(occ);
33 yaz4jlib.delete_size_tp(occ);
34 yaz4jlib.delete_size_tp(length);
35 return new ScanTerm(term, occurences);
38 public long getSize() {
44 yaz4jlib.ZOOM_scanset_destroy(scanSet);
52 public Iterator<ScanTerm> iterator() {
53 return new Iterator<ScanTerm>() {
56 public boolean hasNext() {
61 public ScanTerm next() {
66 public void remove() {
67 throw new UnsupportedOperationException("remove operation not supported");