开发者

How to use paging for retrieving Google docs?

开发者 https://www.devze.com 2023-04-03 01:23 出处:网络
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/\";

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号