Use Java naming conventions
[yaz4j-moved-to-github.git] / src / main / java / org / yaz4j / ScanSet.java
1 package org.yaz4j;
2
3 import org.yaz4j.jni.SWIGTYPE_p_ZOOM_scanset_p;
4 import org.yaz4j.jni.SWIGTYPE_p_int;
5 import org.yaz4j.jni.SWIGTYPE_p_size_t;
6 import org.yaz4j.jni.yaz4jlib;
7
8 public class ScanSet {
9
10     private SWIGTYPE_p_ZOOM_scanset_p scanSet = null;
11     private Connection connection;
12     private boolean disposed = false;
13
14     ScanSet(SWIGTYPE_p_ZOOM_scanset_p scanSet, Connection connection) {
15         this.connection = connection;
16         this.scanSet = scanSet;
17     }
18
19     public void finalize() {
20         dispose();
21     }
22
23     public ScanTerm get(long index) {
24         SWIGTYPE_p_size_t occ = yaz4jlib.new_size_tp();
25         SWIGTYPE_p_size_t length = yaz4jlib.new_size_tp();
26         String term = yaz4jlib.ZOOM_scanset_term(scanSet, (long) index, occ, length);
27         long occurences = yaz4jlib.size_tp_value(occ);
28         yaz4jlib.delete_size_tp(occ);
29         yaz4jlib.delete_size_tp(length);
30         return new ScanTerm(term, occurences);
31     }
32
33     public long getSize() {
34         return yaz4jlib.ZOOM_scanset_size(scanSet);
35     }
36
37     public void dispose() {
38         if (!disposed) {
39             yaz4jlib.ZOOM_scanset_destroy(scanSet);
40             connection = null;
41             scanSet = null;
42             disposed = true;
43         }
44     }
45 }