2011-09-07 21 views
0

我使用Java客户端库通过分页接收带有分页的Google文档信息。 我的代码:如何使用分页检索Google文档?

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(); 
} 

而且处理条目:

List<DocumentListEntry> docList = gDocumentsRetriever.getAllDocs(); 
for (DocumentListEntry entry : docList) { 
    processEntry(oAuthToken, gDocumentsRetriever, entry); 
} 

我得到两个entries.But如果我改变

query.setStartIndex(1); 

query.setStartIndex(3); 

我得到相同的两个条目。

+0

你能发布整个代码片段吗? –

+0

我更新了我的问题。 – Hleb

回答