public Request getRequestForPagedResults ( PagingDirection direction ) { String link = null ; if ( graphObject != null ) { PagedResults pagedResults = graphObject . cast ( PagedResults . class ) ; PagingInfo pagingInfo = pagedResults . getPaging ( ) ; if ( pagingInfo != null ) { if ( direction == PagingDirection . NEXT ) { link = pagingInfo . getNext ( ) ; } else { link = pagingInfo . getPrevious ( ) ; } } } if ( Utility . isNullOrEmpty ( link ) ) { return null ; } if ( link != null && link . equals ( request . getUrlForSingleRequest ( ) ) ) { // We got the same "next" link as we just tried to retrieve. This could happen if cached // data is invalid. All we can do in this case is pretend we have finished. return null ; } Request pagingRequest ; try { pagingRequest = new Request ( request . getSession ( ) , new URL ( link ) ) ; } catch ( MalformedURLException e ) { return null ; } return pagingRequest ; }
If a Response contains results that contain paging information returns a new Request that will retrieve the next page of results in whichever direction is desired . If no paging information is available returns null .