X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fyaz4j%2FResultSet.java;h=b2fd11958beb65d303f0ceef91cf1afcf7cfa3e3;hb=8c7413fbaf0870975229e8e101f79096b5dfe6f0;hp=e2df507fa0a563288a6078950d8ec58dc338db15;hpb=0fc1f63976f5c3022a7d1cb07fc01d33cddbd869;p=yaz4j-moved-to-github.git diff --git a/src/main/java/org/yaz4j/ResultSet.java b/src/main/java/org/yaz4j/ResultSet.java index e2df507..b2fd119 100644 --- a/src/main/java/org/yaz4j/ResultSet.java +++ b/src/main/java/org/yaz4j/ResultSet.java @@ -12,20 +12,20 @@ import org.yaz4j.jni.yaz4jlib; /** * This class represents a "buffered handle" to the result set created on the - * server and thus retrieving records may invlove a request to the server if + * server and thus retrieving records may involve a request to the server if * those records are not locally cached. Details on how to configure the retrieval * (present) process are available in the YAZ manual * * @see YAZ ZOOM result sets * - * Becacuse of the server misbehaviour or errors during retrieval the + * Because of server misbehavior or errors during retrieval the * "getRecord" method may either return null or throw exceptions, even when the * index of retrieved records lies within the bounds of the set. Client * code should be prepared for such situations. * * This class implements the iterable interface and as such can be used within - * foreach loops, it's important to note however that in this case the errors - * during retrieval will be masked with standard NoSuchElementExceptions + * foreach loops, it's important to note, however, that in this case the errors + * during retrieval will be masked with standard NoSuchElementExceptions. * * @author jakub */ @@ -82,10 +82,22 @@ public class ResultSet implements Iterable { return new Record(record, this); } + /** + * Retrieve a collection of records at once. If a record cannot be retrieved, + * it is omitted from the list (thus the list size may be smaller than 'count'). + * @param start start index within the result set + * @param count number of records to retrieve + * @return + * @throws ZoomException raised in case of protocol errors + */ public List getRecords(long start, int count) throws ZoomException { List out = new ArrayList(count); SWIGTYPE_p_p_ZOOM_record_p recs = yaz4jlib.new_zoomRecordArray(count); yaz4jlib.ZOOM_resultset_records(resultSet, recs, start, count); + ZoomException err = this.conn.getZoomException(); + if (err != null) { + throw err; + } for (int i = 0; i < count; i++) { SWIGTYPE_p_ZOOM_record_p record = yaz4jlib.zoomRecordArray_getitem(recs, i); @@ -126,6 +138,13 @@ public class ResultSet implements Iterable { }; } + /** + * + * @param type + * @param spec + * @return + * @throws ZoomException + */ public ResultSet sort(String type, String spec) throws ZoomException { int ret = yaz4jlib.ZOOM_resultset_sort1(resultSet, type, spec); if (ret != 0) throw new ZoomException("Sorting resultset failed");