code: private void ensureAvailable(int index) {
          if (data.get(index) != null) {
              // Already have this item.
              return;
          }
          if (client == null) {
              throw new RuntimeException("no remoting client configured");
          }
          Object result;
          int start = index;
          int count;
          if (mode.equals(MODE_ONDEMAND)) {
              // Only get requested item
              count = 1;
          } else if (mode.equals(MODE_FETCHALL)) {
              // Get remaining items
              count = totalCount - cursor;
          } else if (mode.equals(MODE_PAGE)) {
              // Get next page
              // TODO: implement prefetching of multiple pages
              count = 1;
              for (int i = 1; i < pageSize; i++) {
                  if (this.data.get(start + i) == null) {
                      count += 1;
                  }
              }
          } else {
              // Default to "ondemand"
              count = 1;
          }
  
          result = client.invokeMethod(serviceName + ".getRecords", new Object[] { id, start + 1, count });
          if (!(result instanceof RecordSetPage)) {
              throw new RuntimeException("expected RecordSetPage but got " + result);
          }
  
          RecordSetPage page = (RecordSetPage) result;
          if (page.getCursor() != start + 1) {
              throw new RuntimeException("expected offset " + (start + 1) + " but got " + page.getCursor());
          }
  
          List<List<Object>> data = page.getData();
          if (data.size() != count) {
              throw new RuntimeException("expected " + count + " results but got " + data.size());
          }
  
          // Store received items
          for (int i = 0; i < count; i++) {
              this.data.add(start + i, data.get(i));
          }
      }
docs: Make sure the passed item has been fetched from the server.
  
  @param index
  Item index