Return null if a record cannot be retrieved.
[yaz4j-moved-to-github.git] / src / main / java / org / yaz4j / ScanSet.java
index 819ac1a..3eaea94 100644 (file)
@@ -1,31 +1,31 @@
 package org.yaz4j;
 
 import org.yaz4j.jni.SWIGTYPE_p_ZOOM_scanset_p;
-import org.yaz4j.jni.SWIGTYPE_p_int;
+import org.yaz4j.jni.SWIGTYPE_p_size_t;
 import org.yaz4j.jni.yaz4jlib;
 
 public class ScanSet {
-
-    private SWIGTYPE_p_ZOOM_scanset_p scanSet = null;
-    private Connection connection;
+    //for GC ref-count
+    private Connection conn;
+    private SWIGTYPE_p_ZOOM_scanset_p scanSet;
     private boolean disposed = false;
 
-    ScanSet(SWIGTYPE_p_ZOOM_scanset_p scanSet, Connection connection) {
-        this.connection = connection;
+    ScanSet(SWIGTYPE_p_ZOOM_scanset_p scanSet, Connection conn) {
         this.scanSet = scanSet;
+        this.conn = conn;
     }
 
     public void finalize() {
-        Dispose();
+        _dispose();
     }
 
     public ScanTerm get(long index) {
-        SWIGTYPE_p_int occ = yaz4jlib.new_intp();
-        SWIGTYPE_p_int length = yaz4jlib.new_intp();
+        SWIGTYPE_p_size_t occ = yaz4jlib.new_size_tp();
+        SWIGTYPE_p_size_t length = yaz4jlib.new_size_tp();
         String term = yaz4jlib.ZOOM_scanset_term(scanSet, (long) index, occ, length);
-        int occurences = yaz4jlib.intp_value(occ);
-        yaz4jlib.delete_intp(occ);
-        yaz4jlib.delete_intp(length);
+        long occurences = yaz4jlib.size_tp_value(occ);
+        yaz4jlib.delete_size_tp(occ);
+        yaz4jlib.delete_size_tp(length);
         return new ScanTerm(term, occurences);
     }
 
@@ -33,11 +33,11 @@ public class ScanSet {
         return yaz4jlib.ZOOM_scanset_size(scanSet);
     }
 
-    public void Dispose() {
+    void _dispose() {
         if (!disposed) {
             yaz4jlib.ZOOM_scanset_destroy(scanSet);
-            connection = null;
             scanSet = null;
+            conn = null;
             disposed = true;
         }
     }