public String getPageLinks() {
        final StringBuilder sb = new StringBuilder();
        final int beginningEndPage = Math.min(3, totalPages);
        appendLinkToPages(sb, 1, beginningEndPage);

        final int middleStartPage = Math.max(currentPage - 2, beginningEndPage + 1);
        final int middleEndPage = Math.min(currentPage + 2, totalPages);

        if (middleStartPage > (beginningEndPage + 1)) {
            sb.append("\n<span> ... </span>");
        }
        appendLinkToPages(sb, middleStartPage, middleEndPage);

        final int endStartPage = Math.max(totalPages - 2, middleEndPage + 1);
        if (endStartPage > (middleEndPage + 1)) {
            sb.append("\n<span> ... </span>");
        }

        appendLinkToPages(sb, endStartPage, totalPages);

        return sb.toString();
    }
@return a string that contains links to other pages in the list
xmppserver/src/main/java/org/jivesoftware/util/ListPager.java