// in the list results.\r
//\r
// FIXME: There may well be a pattern-based way to do this\r
- // in our framework.\r
+ // in our framework, and if we can eliminate much of the\r
+ // non-DRY code below, that would be desirable.\r
+ \r
int startIndex = 0;\r
int endIndex = 0;\r
+ \r
// Return all results if pageSize is 0.\r
if (pageSize == 0) {\r
startIndex = 0;\r
startIndex = pageNum * pageSize;\r
}\r
\r
- // Return an empty list if the start of the requested page is\r
+ // Return an empty list when the start of the requested page is\r
// beyond the last item in the list.\r
if (startIndex > list.size()) {\r
- wrapperList = null;\r
+ wrapperList.getAuthorityRefDocItem().clear();\r
+ commonList.setItemsInPage(wrapperList.getAuthorityRefDocItem().size());\r
return wrapperList;\r
}\r
\r
// Otherwise, return a list of items from the start of the specified\r
- // page through the last item on that page, or otherwise through the last\r
- // item in the entire list, if it occurs prior to the end of that page.\r
+ // page through the last item on that page, or otherwise through the\r
+ // last item in the entire list, if that occurs earlier than the end\r
+ // of the specified page.\r
if (endIndex == 0) {\r
int pageEndIndex = ((startIndex + pageSize));\r
endIndex = (pageEndIndex > list.size()) ? list.size() : pageEndIndex;\r
}\r
\r
- // Slice the list to return only the specified page.\r
- // Note: the second argument to List.subList() is exclusive of the\r
- // item at its index position, reflecting the zero-index nature of\r
- // the list.\r
+ // Slice the list to return only the specified page of results.\r
+ // Note: the second argument to List.subList(), endIndex, is\r
+ // exclusive of the item at its index position, reflecting the\r
+ // zero-index nature of the list.\r
List<AuthorityRefDocList.AuthorityRefDocItem> currentPageList =\r
new ArrayList<AuthorityRefDocList.AuthorityRefDocItem>(list.subList(startIndex, endIndex));\r
wrapperList.getAuthorityRefDocItem().clear();\r