private void calculatePageInfo(int pageSize) {
        // if not paging,pageSize should be less than 0
        if (pageSize <= 0) {
            return;
        }

        if (totalCount == 0) {
            this.totalPageNumber = 0;
        } else {
            long left = totalCount % pageSize;
            this.totalPageNumber = (totalCount / pageSize) + (left > 0 ? 1 : 0);
        }

        // calculate start index and end index
        if (totalPageNumber == 0) {
            this.startIndex = 0;
            this.endIndex = 0;
        } else if (pageSize > totalCount) {
            this.startIndex = 1;
            this.endIndex = totalCount;
        } else {
            this.startIndex = (currentPageNumber - 1) * pageSize + 1;
            this.endIndex = currentPageNumber < totalPageNumber ? (startIndex
                    + pageSize - 1) : totalCount;
        }

        // calculate has pre or has next
        if (currentPageNumber == 1) {
            hasPre = false;
        } else {
            hasPre = true;
        }
        if (totalCount == 0) {
            hasNext = false;
        } else if (currentPageNumber == totalPageNumber) {
            hasNext = false;
        } else {
            hasNext = true;
        }
    }