private List<T> computePagedList(List<T> result, HeaderAndBody httpResponse, JSONObject where, Pipe<T> requestingPipe) {
        ReadFilter previousRead = null;
        ReadFilter nextRead = null;

        if (PageConfig.MetadataLocations.WEB_LINKING.equals(pageConfig.getMetadataLocation())) {
            String webLinksRaw = "";
            final String relHeader = "rel";
            final String nextIdentifier = pageConfig.getNextIdentifier();
            final String prevIdentifier = pageConfig.getPreviousIdentifier();
            try {
                webLinksRaw = getWebLinkHeader(httpResponse);
                if (webLinksRaw == null) { // no paging, return result
                    return result;
                }
                List<WebLink> webLinksParsed = WebLinkParser.parse(webLinksRaw);
                for (WebLink link : webLinksParsed) {
                    if (nextIdentifier.equals(link.getParameters().get(relHeader))) {
                        nextRead = new ReadFilter();
                        nextRead.setLinkUri(new URI(link.getUri()));
                    } else if (prevIdentifier.equals(link.getParameters().get(relHeader))) {
                        previousRead = new ReadFilter();
                        previousRead.setLinkUri(new URI(link.getUri()));
                    }

                }
            } catch (URISyntaxException ex) {
                Log.e(TAG, webLinksRaw + " did not contain a valid context URI", ex);
                throw new RuntimeException(ex);
            } catch (ParseException ex) {
                Log.e(TAG, webLinksRaw + " could not be parsed as a web link header", ex);
                throw new RuntimeException(ex);
            }
        } else if (pageConfig.getMetadataLocation().equals(PageConfig.MetadataLocations.HEADERS)) {
            nextRead = pageConfig.getPageParameterExtractor().getNextFilter(httpResponse, RestAdapter.this.pageConfig);
            previousRead = pageConfig.getPageParameterExtractor().getPreviousFilter(httpResponse, RestAdapter.this.pageConfig);
        } else if (pageConfig.getMetadataLocation().equals(PageConfig.MetadataLocations.BODY)) {
            nextRead = pageConfig.getPageParameterExtractor().getNextFilter(httpResponse, RestAdapter.this.pageConfig);
            previousRead = pageConfig.getPageParameterExtractor().getPreviousFilter(httpResponse, RestAdapter.this.pageConfig);
        } else {
            throw new IllegalStateException("Not supported");
        }
        if (nextRead != null) {
            nextRead.setWhere(where);
        }

        if (previousRead != null) {
            previousRead.setWhere(where);
        }

        return new WrappingPagedList<T>(requestingPipe, result, nextRead, previousRead);
    }
private List < T > computePagedList ( List < T > result , HeaderAndBody httpResponse , JSONObject where , Pipe < T > requestingPipe ) { ReadFilter previousRead = null ; ReadFilter nextRead = null ; if ( PageConfig . MetadataLocations . WEB_LINKING . equals ( pageConfig . getMetadataLocation ( ) ) ) { String webLinksRaw = "" ; final String relHeader = "rel" ; final String nextIdentifier = pageConfig . getNextIdentifier ( ) ; final String prevIdentifier = pageConfig . getPreviousIdentifier ( ) ; try { webLinksRaw = getWebLinkHeader ( httpResponse ) ; if ( webLinksRaw == null ) { return result ; } List < WebLink > webLinksParsed = WebLinkParser . parse ( webLinksRaw ) ; for ( WebLink link : webLinksParsed ) { if ( nextIdentifier . equals ( link . getParameters ( ) . get ( relHeader ) ) ) { nextRead = new ReadFilter ( ) ; nextRead . setLinkUri ( new URI ( link . getUri ( ) ) ) ; } else if ( prevIdentifier . equals ( link . getParameters ( ) . get ( relHeader ) ) ) { previousRead = new ReadFilter ( ) ; previousRead . setLinkUri ( new URI ( link . getUri ( ) ) ) ; } } } catch ( URISyntaxException ex ) { Log . e ( TAG , webLinksRaw + " did not contain a valid context URI" , ex ) ; throw new RuntimeException ( ex ) ; } catch ( ParseException ex ) { Log . e ( TAG , webLinksRaw + " could not be parsed as a web link header" , ex ) ; throw new RuntimeException ( ex ) ; } } else if ( pageConfig . getMetadataLocation ( ) . equals ( PageConfig . MetadataLocations . HEADERS ) ) { nextRead = pageConfig . getPageParameterExtractor ( ) . getNextFilter ( httpResponse , RestAdapter . this . pageConfig ) ; previousRead = pageConfig . getPageParameterExtractor ( ) . getPreviousFilter ( httpResponse , RestAdapter . this . pageConfig ) ; } else if ( pageConfig . getMetadataLocation ( ) . equals ( PageConfig . MetadataLocations . BODY ) ) { nextRead = pageConfig . getPageParameterExtractor ( ) . getNextFilter ( httpResponse , RestAdapter . this . pageConfig ) ; previousRead = pageConfig . getPageParameterExtractor ( ) . getPreviousFilter ( httpResponse , RestAdapter . this . pageConfig ) ; } else { throw new IllegalStateException ( "Not supported" ) ; } if ( nextRead != null ) { nextRead . setWhere ( where ) ; } if ( previousRead != null ) { previousRead . setWhere ( where ) ; } return new WrappingPagedList < T > ( requestingPipe , result , nextRead , previousRead ) ; }
This method checks for paging information and returns the appropriate
data

@param result
@param httpResponse
@param where
@return a {@link WrappingPagedList} if there is paging, result if not.