org.n3r.quartz.glass.util.Page Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quartz-glass Show documentation
Show all versions of quartz-glass Show documentation
A web user interface for quartz
package org.n3r.quartz.glass.util;
import java.util.ArrayList;
import java.util.List;
/**
* A page of results.
*
* @author damien bourdette
*/
public class Page {
/**
* Query that have been used to get this page.
*/
private Query query;
/**
* All items in current page.
*/
private List items = new ArrayList();
/**
* Total count of items in store.
*/
private int totalCount;
private Page() {
super();
}
public static Page fromQuery(Query query) {
Page page = new Page();
page.query = query;
return page;
}
public int getCount() {
if (totalCount == 0) {
return 1;
}
int pageCount = totalCount / query.getSize();
if (pageCount * query.getSize() != totalCount) {
pageCount += 1;
}
return pageCount;
}
public Query getQuery() {
return query;
}
public List getItems() {
return new ArrayList(items);
}
public void setItems(List items) {
if (items == null) {
throw new IllegalArgumentException("Items can not be null");
}
this.items = new ArrayList(items);
}
public int getTotalCount() {
return totalCount;
}
public void setTotalCount(int totalCount) {
this.totalCount = totalCount;
}
}