Paginator implements Serializable, CloneableObject<Paginator> { public int setItem(int itemOffset) { return setPage(itemOffset / itemsPerPage + 1); } Paginator();  Paginator(int itemsPerPage);  Paginator(int itemsPerPage, int items);  Paginator(PageSize pageSize);  Paginator(PageSize pageSize, int items); int getPages(); int getPage(); int setPage(int page); int getItems(); int setItems(int items); int getItemsPerPage(); int setItemsPerPage(int itemsPerPage); int setItemsPerPage(PageSize pageSize); int getOffset(); int getLength(); int getBeginIndex(); int getEndIndex(); int setItem(int itemOffset); int getFirstPage(); int getLastPage(); int getPreviousPage(); int getPreviousPage(int n); int getNextPage(); int getNextPage(int n); int getPrevious(); int getNext(); boolean isDisabledPage(int page); int[] getSlider(); int[] getSlider(int width); @Override Paginator clone(); @Override String toString(); static final int DEFAULT_ITEMS_PER_PAGE; static final int DEFAULT_SLIDER_SIZE; static final int UNKNOWN_ITEMS; }
@Test public void setItem() { pg.setItems(123); pg.setItem(122); assertEquals(13, pg.getPage()); assertEquals(1, pg.getFirstPage()); assertEquals(12, pg.getPreviousPage()); assertEquals(3, pg.getPreviousPage(10)); assertEquals(13, pg.getNextPage()); assertEquals(13, pg.getNextPage(10)); assertEquals(121, pg.getBeginIndex()); assertEquals(123, pg.getEndIndex()); assertEquals(120, pg.getOffset()); assertEquals(3, pg.getLength()); assertTrue(pg.isDisabledPage(0)); assertFalse(pg.isDisabledPage(1)); assertFalse(pg.isDisabledPage(2)); assertFalse(pg.isDisabledPage(11)); assertTrue(pg.isDisabledPage(13)); assertTrue(pg.isDisabledPage(14)); pg.setItem(0); assertEquals(1, pg.getPage()); assertEquals(1, pg.getFirstPage()); assertEquals(1, pg.getPreviousPage()); assertEquals(1, pg.getPreviousPage(10)); assertEquals(2, pg.getNextPage()); assertEquals(11, pg.getNextPage(10)); assertEquals(13, pg.getLastPage()); assertEquals(1, pg.getBeginIndex()); assertEquals(10, pg.getEndIndex()); assertEquals(0, pg.getOffset()); assertEquals(10, pg.getLength()); assertTrue(pg.isDisabledPage(0)); assertTrue(pg.isDisabledPage(1)); assertFalse(pg.isDisabledPage(2)); assertFalse(pg.isDisabledPage(13)); assertTrue(pg.isDisabledPage(14)); }