}
checkErrorCodeAndThrow(errorCode);
- resultSet = new ResultSet(yazResultSet, zoomConnection);
+ resultSet = new ResultSet(yazResultSet, this);
} finally {
yaz4jlib.ZOOM_query_destroy(yazQuery); // deallocate yazQuery also when exceptions
yazQuery = null;
import org.yaz4j.jni.yaz4jlib;
public class Record {
-
private SWIGTYPE_p_ZOOM_record_p record = null;
- private ResultSet resultSet = null;
private boolean disposed = false;
- Record(SWIGTYPE_p_ZOOM_record_p record, ResultSet resultSet) {
- this.resultSet = resultSet;
+ Record(SWIGTYPE_p_ZOOM_record_p record) {
this.record = record;
}
void _dispose() {
if (!disposed) {
- resultSet = null;
record = null;
disposed = true;
}
package org.yaz4j;
-import org.yaz4j.jni.SWIGTYPE_p_ZOOM_connection_p;
import org.yaz4j.jni.SWIGTYPE_p_ZOOM_record_p;
import org.yaz4j.jni.SWIGTYPE_p_ZOOM_resultset_p;
import org.yaz4j.jni.yaz4jlib;
public class ResultSet {
-
+ //for GC refcount
+ private Connection conn;
private SWIGTYPE_p_ZOOM_resultset_p resultSet;
- private SWIGTYPE_p_ZOOM_connection_p connection;
private long size = 0;
private boolean disposed = false;
- ResultSet(SWIGTYPE_p_ZOOM_resultset_p resultSet, SWIGTYPE_p_ZOOM_connection_p connection) {
+ ResultSet(SWIGTYPE_p_ZOOM_resultset_p resultSet, Connection conn) {
this.resultSet = resultSet;
- this.connection = connection;
size = yaz4jlib.ZOOM_resultset_size(this.resultSet);
+ this.conn = conn;
}
@Override
public Record getRecord(int index) {
SWIGTYPE_p_ZOOM_record_p recordTemp = yaz4jlib.ZOOM_resultset_record(resultSet, index);
- return new Record(recordTemp, this);
+ return new Record(recordTemp);
}
public long getSize() {
void _dispose() {
if (!disposed) {
yaz4jlib.ZOOM_resultset_destroy(resultSet);
- connection = null;
resultSet = null;
+ conn = null;
disposed = true;
}
}
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() {
void _dispose() {
if (!disposed) {
yaz4jlib.ZOOM_scanset_destroy(scanSet);
- connection = null;
scanSet = null;
+ conn = null;
disposed = true;
}
}