org.eclipse.egit.github.core.client
Class PageIterator<V>

java.lang.Object
  extended by org.eclipse.egit.github.core.client.PageIterator<V>
Type Parameters:
V - type of resource being iterated over
All Implemented Interfaces:
Iterable<Collection<V>>, Iterator<Collection<V>>

public class PageIterator<V>
extends Object
implements Iterator<Collection<V>>, Iterable<Collection<V>>

Iterator for getting paged responses. Each call to next() will make a client request for the next page of resources using the URI returned from the previous request. The hasNext() method can be used to determine if the last executed request contained the location of the next page of results. This iterator also provides the next and last page numbers as well as the next and last URIs.


Field Summary
protected  GitHubClient client
          Client
protected  String last
          Last uri to be fetched
protected  int lastPage
          Last page number
protected  String next
          Next uri to be fetched
protected  int nextPage
          Current page number
protected  PagedRequest<V> request
          Request
 
Constructor Summary
PageIterator(PagedRequest<V> request, GitHubClient client)
          Create page iterator
 
Method Summary
 int getLastPage()
          Get number of last page
 String getLastUri()
          Get uri of last page
 int getNextPage()
          Get number of next page to be read
 String getNextUri()
          Get URI of next request
 PagedRequest<V> getRequest()
          Get request being executed
 boolean hasNext()
           
 Iterator<Collection<V>> iterator()
           
 Collection<V> next()
           
protected  int parsePageNumber(String uri)
          Parse page number from uri
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

request

protected final PagedRequest<V> request
Request


client

protected final GitHubClient client
Client


nextPage

protected int nextPage
Current page number


lastPage

protected int lastPage
Last page number


next

protected String next
Next uri to be fetched


last

protected String last
Last uri to be fetched

Constructor Detail

PageIterator

public PageIterator(PagedRequest<V> request,
                    GitHubClient client)
Create page iterator

Parameters:
request -
client -
Method Detail

parsePageNumber

protected int parsePageNumber(String uri)
Parse page number from uri

Parameters:
uri -
Returns:
page number

getNextPage

public int getNextPage()
Get number of next page to be read

Returns:
next page

getLastPage

public int getLastPage()
Get number of last page

Returns:
page number

getNextUri

public String getNextUri()
Get URI of next request

Returns:
next page uri

getLastUri

public String getLastUri()
Get uri of last page

Returns:
last page uri

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<Collection<V>>

remove

public void remove()
Specified by:
remove in interface Iterator<Collection<V>>

next

public Collection<V> next()
Specified by:
next in interface Iterator<Collection<V>>

getRequest

public PagedRequest<V> getRequest()
Get request being executed

Returns:
request

iterator

public Iterator<Collection<V>> iterator()
Specified by:
iterator in interface Iterable<Collection<V>>
Returns:
this page iterator


Copyright © 2012. All Rights Reserved.