Creates a 'LIMIT .. OFFSET .. ORDER BY ..' clause for the given {@link DataTablesInput}.

@return a {@link Pageable}, must not be {@literal null}.
191686
public Pageable createPageable() {
        List<Sort.Order> orders = new ArrayList<>();
        for (org.springframework.data.jpa.datatables.mapping.Order order : input.getOrder()) {
            Column column = input.getColumns().get(order.getColumn());
            if (column.getOrderable()) {
                String sortColumn = column.getData();
                Sort.Direction sortDirection = Sort.Direction.fromString(order.getDir());
                orders.add(new Sort.Order(sortDirection, sortColumn));
            }
        }
        Sort sort = orders.isEmpty() ? Sort.unsorted() : Sort.by(orders);

        if (input.getLength() == -1) {
            input.setStart(0);
            input.setLength(Integer.MAX_VALUE);
        }
        return new DataTablesPageRequest(input.getStart(), input.getLength(), sort);
    }
1186070
public static <T> DataPage<T> getByList(List<T> list, int pageSize, int pageNo) {
        List<T> l = subList(list, pageSize, pageNo);
        return new DataPage<T>(l, list.size(), pageSize, pageNo);
    }
1021397
function(table, limit, page, query, fields)
    {
        if (this._doneLoading)
            return;

        var _this = this;

        // Execute -- add orderBy and ascending?
        var args = [table, limit, page, query, fields];
        if (this._orderBy) {
            args.push(this._orderBy);
            args.push(this._ascending);
        }

        var p = this.dataService.query.apply(this.dataService.query, args)

        // Pack results back into <T> and add it to our _results array
        .then(function(results) {
            results.forEach(function(r) {
                var obj = new _this._T();
                _(r).each(function(value, key) {
                    obj[key] = value;
                });
                _this._results.push(obj);
            });

            // If we hit the last page
            if (results.length !== limit)
                _this._doneLoading = true;

            return _this._results;
        });

        return p;
    }
712552
@SuppressWarnings("WeakerAccess")
	public static @Nullable
	Pageable toPage(final int theFromIndex, int theToIndex) {
		int pageSize = theToIndex - theFromIndex;
		if (pageSize < 1) {
			return null;
		}

		int pageIndex = theFromIndex / pageSize;

		Pageable page = new AbstractPageRequest(pageIndex, pageSize) {
			private static final long serialVersionUID = 1L;

			@Override
			public long getOffset() {
				return theFromIndex;
			}

			@Override
			public Sort getSort() {
				return Sort.unsorted();
			}

			@Override
			public Pageable next() {
				return null;
			}

			@Override
			public Pageable previous() {
				return null;
			}

			@Override
			public Pageable first() {
				return null;
			}
		};

		return page;
	}
1091785
public TableOperation createLimitWithFetch(int fetch, TableOperation child) {
		SortTableOperation previousSort = validateAndGetChildSort(child);

		if (fetch < 0) {
			throw new ValidationException("Fetch should be greater or equal 0");
		}

		int offset = Math.max(previousSort.getOffset(), 0);

		return new SortTableOperation(previousSort.getOrder(), previousSort.getChild(), offset, fetch);
	}
284478
private void setPageTotalCount(Connection connection, MappedStatement mappedStatement, BoundSql boundSql) {
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;
        try {
            preparedStatement = connection.prepareStatement(createCountSql(boundSql.getSql()));
            ParameterHandler parameterHandler = new DefaultParameterHandler(mappedStatement, boundSql.getParameterObject(), boundSql);
            parameterHandler.setParameters(preparedStatement);
            resultSet = preparedStatement.executeQuery();
            if (resultSet.next()) {
                ((PageEntity) boundSql.getParameterObject()).setTotalCount(resultSet.getLong(1));
            }
            if (resultSet != null) resultSet.close();
            if (preparedStatement != null) preparedStatement.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
1070427
public static <T> OffsetPaginatedList.Builder<T> builder() {
    return new AutoValue_OffsetPaginatedList.Builder<T>().items(new ArrayList<>())
        .metadata(
            LimitParameter.getDefaultLimitFieldName(), null,
            OffsetParameter.getDefaultOffsetFieldName(), null, null, null);
  }
222802
@Override
    public PaginatedList queryForPaginatedList(String statementName, Object parameterObject,
                                               int pageSize) throws DataAccessException {
        return super.queryForPaginatedList(statementName, parameterObject, pageSize);
    }
182143
private PdfPTable buildPdfTable(int type) throws QueryException {

        List<Band> bands = new ArrayList<Band>();
        if (type == PRINT_PAGE_HEADER) {        	        	
        	bands.add(getReportLayout().getPageHeaderBand());
        } else if (type == PRINT_PAGE_FOOTER) {
        	bands.add(getReportLayout().getPageFooterBand());        
        } else {
        	bands = getReportLayout().getDocumentBands();
        }
        int totalRows = 0;
        int totalColumns = 0;
        for (Band band : bands) {
            totalRows += band.getRowCount();
            int cols = band.getColumnCount();
            if (cols > totalColumns) {
                totalColumns = cols;
            }
        }

        // no page header or no page footer
        if (totalColumns == 0) {
        	return null;
        }
        PdfPTable datatable = new PdfPTable(totalColumns);
                
        // !Important: when a cell is bigger than a page it won't show
        // we could use datatable.setSplitLate(false)and in this case we can see
        // some content but it is very ugly.
        
        headerwidths = new int[totalColumns]; // %

        int size = 100 / totalColumns;
        int totalWidth = 0;
        for (int i = 0; i < totalColumns; i++) {
            if (bean.getReportLayout().isUseSize()) {
                headerwidths[i] = bean.getReportLayout().getColumnsWidth().get(i);
            } else {
                headerwidths[i] = size;
            }
            totalWidth += headerwidths[i];
        }
        try {            
            if (bean.getReportLayout().isUseSize()) {
                float pixels = A4_PORTRAIT_PIXELS;
                if (bean.getReportLayout().getOrientation() == LANDSCAPE) {
                    pixels = A4_LANDSCAPE_PIXELS;
                }
                percentage = totalWidth * 100 / pixels;
                // do not allow to go outside an A4 frame
                if (percentage > 100) {
                    percentage = 100;
                }
                if (!ReportLayout.CUSTOM.equals(bean.getReportLayout().getPageFormat())) {
                	datatable.setWidthPercentage(percentage);
                }
                datatable.setWidths(headerwidths);
            } else {
                datatable.setWidthPercentage(100);
            }            
        } catch (DocumentException e) {
            throw new QueryException(e);
        }
        if (type == PRINT_DOCUMENT) {
        	writeHeader(datatable);
        }
        // this is used in correlation with sepSplitRows(true) which is the default inside PdfPTable;
        // by default splitLate is true and in case a subreport is bigger than a page, the subreport
        // will be written starting from next page, leaving first page empty
        datatable.setSplitLate(false);
        return datatable;
    }
181412
@Override
    public Iterator<Table> listTables(@Nullable String fromTableExclusive, long limit) {
        return _delegate.listTables(fromTableExclusive, limit);
    }
750214
@Override
    public PaginatedList queryForPaginatedList(String statementName, int pageSize)
            throws DataAccessException {
        return super.queryForPaginatedList(statementName, pageSize);
    }
852452
public Query orderedBy( List<Ordering> orderings ) {
        return new Query(source, constraint, orderings, columns, getLimits(), distinct);
    }
210269
public static <T extends Offset<T>> Ordering<OffsetRange<T>> byEarlierStartEarlierEndOrdering() {
    return Ordering.<T>natural().onResultOf(OffsetRange.<T>toStartInclusiveFunction())
        .compound(Ordering.<T>natural().onResultOf(OffsetRange.<T>toEndInclusiveFunction()));
  }
697855
private StringBuilder appendPagingSortSQL(final StringBuilder sql, final Post.Sort sort,final Paging paging) {

      if(paging.interval != null) {
         sql.append(" AND post_date");
         sql.append(paging.startIsOpen ? " >" : " >=");
         sql.append("?");

         sql.append(" AND post_date");
         sql.append(paging.endIsOpen ? " <" : " <=");
         sql.append("?");
      }

      switch(sort) {
         case ASC:
            sql.append(" ORDER BY post_date ASC");
            break;
         case DESC:
            sql.append(" ORDER BY post_date DESC");
            break;
         case ASC_MOD:
            sql.append(" ORDER BY post_modified ASC");
            break;
         case DESC_MOD:
            sql.append(" ORDER BY post_modified DESC");
            break;
         case ID_ASC:
            sql.append(" ORDER BY ID ASC");
            break;
         case ID_DESC:
            sql.append(" ORDER BY ID DESC");
            break;
         default:
            sql.append(" ORDER BY post_date DESC");
            break;
      }
      sql.append(" LIMIT ?,?");
      return sql;
   }
351770
private <K, C> Iterator<Column<C>> executePaginated(final RowQuery<K, C> query) {
        return Iterators.concat(new AbstractIterator<Iterator<Column<C>>>() {
            @Override
            protected Iterator<Column<C>> computeNext() {
                ColumnList<C> page = execute(query);
                return !page.isEmpty() ? page.iterator() : endOfData();
            }
        });
    }
403622
@Override
    public Iterator<MultiTableScanResult> multiTableScan(final MultiTableScanOptions query, final TableSet tables,
                                                         final LimitCounter limit, final ReadConsistency consistency, @Nullable Instant cutoffTime) {
        checkNotNull(query, "query");
        String placementName = checkNotNull(query.getPlacement(), "placement");
        final DeltaPlacement placement = (DeltaPlacement) _placementCache.get(placementName);

        ScanRange scanRange = Objects.firstNonNull(query.getScanRange(), ScanRange.all());

        // Since the range may wrap from high to low end of the token range we need to unwrap it
        List<ScanRange> ranges = scanRange.unwrapped();

        return touch(FluentIterable.from(ranges)
                .transformAndConcat(new Function<ScanRange, Iterable<MultiTableScanResult>>() {
                    @Override
                    public Iterable<MultiTableScanResult> apply(final ScanRange rowRange) {
                        return new Iterable<MultiTableScanResult>() {
                            @Override
                            public Iterator<MultiTableScanResult> iterator() {
                                return scanMultiTableRows(
                                        tables, placement, rowRange.asByteBufferRange(), limit, query.isIncludeDeletedTables(),
                                        query.isIncludeMirrorTables(), _maxColumnsRange.getLimit(), consistency, cutoffTime);
                            }
                        };
                    }
                })
                .iterator());

    }
429047
public static <T> Pagination<T> build(final Long offset, final Long limit, final Collection<T> elements) {
        return build(offset, limit, elements.size(), elements);
    }