*/
public PaginatedInstanceUsage retrievePaginatedInstanceUsage(String yearMonth, int pageNumber,
int entriesPerPage) throws Exception {
InstanceUsageStatics[] instanceUsages = retrieveInstanceUsage();
List<InstanceUsageStatics> instanceUsagesList = new ArrayList<InstanceUsageStatics>();
PaginatedInstanceUsage paginatedInstanceUsages = new PaginatedInstanceUsage();
int i = 0;
int numberOfPages = 0;
if (instanceUsages != null && instanceUsages.length > 0) {
for (InstanceUsageStatics usage : instanceUsages) {
InstanceUsageStatics instance = getValidUsageEntry(usage, yearMonth);
if (instance != null) {
if (i % entriesPerPage == 0) {
numberOfPages++;
}
}
}
paginatedInstanceUsages.setInstanceUsages(
instanceUsagesList.toArray(new InstanceUsageStatics[instanceUsagesList.size()]));
} else {
paginatedInstanceUsages.setInstanceUsages(null);
}
paginatedInstanceUsages.setNumberOfPages(numberOfPages);
paginatedInstanceUsages.setPageNumber(pageNumber);
return paginatedInstanceUsages;
}