I wand to receive google docs info with paging using Java Client Library. My code:
private static final String URL_STRING = "https://docs.google.com/feeds/default/private/full/";
public List<DocumentListEntry> getAllDocs() throws Exception {
URL feedUri = new URL(URL_STRING);
DocumentQuery query = new DocumentQuery(feedUri);
query.setMaxResults(2);
query.setStartIndex(1);
DocumentListFeed feed = client.getFeed(query, DocumentListFeed.class);
return feed.getEntries();
}
And processing entries:
List<DocumentListEntry> docList = gDocumentsRetriever.getAllD开发者_开发知识库ocs();
for (DocumentListEntry entry : docList) {
processEntry(oAuthToken, gDocumentsRetriever, entry);
}
I get two entries.But if I change
query.setStartIndex(1);
to
query.setStartIndex(3);
i get same two entries.
I found how this issue can be realized: http://code.google.com/apis/documents/docs/3.0/developers_guide_java.html#pagingThroughResults
For other services it realizes in the same way.
精彩评论