SortOrder

A sort order represents an ORDER BY clause in a query.

Methods
static int addExplicitNullPosition(int sortType)
Returns a sort type bit mask with
static int addExplicitNullPosition(int sortType)
Returns a sort type bit mask with {@link #NULLS_FIRST} or {@link #NULLS_LAST} explicitly set, depending on {@link SysProperties#SORT_NULLS_HIGH}.
Parameters:
sortType - sort type bit mask
Returns:
bit mask with either {@link #NULLS_FIRST} or {@link #NULLS_LAST} explicitly set.
static int compareNull(boolean aNull, int sortType)
Compare two expressions where one of them is NULL.
static int compareNull(boolean aNull, int sortType)
Compare two expressions where one of them is NULL.
Parameters:
aNull - whether the first expression is null
sortType - the sort bit mask to use
Returns:
the result of the comparison (-1 meaning the first expression should appear before the second, 0 if they are equal)
SortOrder(Database database, int[] queryColumnIndexes, int[] sortType, ArrayList orderList)
Construct a new sort order object.
SortOrder(Database database, int[] queryColumnIndexes, int[] sortType, ArrayList orderList)
Construct a new sort order object.
Parameters:
database - the database
queryColumnIndexes - the column index list
sortType - the sort order bit masks
orderList - the original query order list (if this is a query)
int compare(Value[] a, Value[] b)
Compare two expression lists.
int compare(Value[] a, Value[] b)
Compare two expression lists.
Parameters:
a - the first expression list
b - the second expression list
Returns:
the result of the comparison
Column getColumn(int index, TableFilter filter)
Get the column for the given table filter, if the sort column is for this filter.
Column getColumn(int index, TableFilter filter)
Get the column for the given table filter, if the sort column is for this filter.
Parameters:
index - the column index (0, 1,..)
filter - the table filter
Returns:
the column, or null
int[] getQueryColumnIndexes()
Get the column index list.
int[] getQueryColumnIndexes()
Get the column index list. This is the column indexes of the order by expressions within the query.

For the query "select name, id from test order by id, name" this is {1, 0} as the first order by expression (the column "id") is the second column of the query, and the second order by expression ("name") is the first column of the query.

Returns:
the list
String getSQL(Expression[] list, int visible)
Create the SQL snippet that describes this sort order.
String getSQL(Expression[] list, int visible)
Create the SQL snippet that describes this sort order. This is the SQL snippet that usually appears after the ORDER BY clause.
Parameters:
list - the expression list
visible - the number of columns in the select list
Returns:
the SQL snippet
int[] getSortTypes()
Get the sort order bit masks.
int[] getSortTypes()
Get the sort order bit masks.
Returns:
the list
int[] getSortTypesWithNullPosition()
Returns sort order bit masks with
int[] getSortTypesWithNullPosition()
Returns sort order bit masks with {@link #NULLS_FIRST} or {@link #NULLS_LAST} explicitly set, depending on {@link SysProperties#SORT_NULLS_HIGH}.
Returns:
bit masks with either {@link #NULLS_FIRST} or {@link #NULLS_LAST} explicitly set.
void sort(ArrayList rows)
Sort a list of rows.
void sort(ArrayList rows)
Sort a list of rows.
Parameters:
rows - the list of rows
void sort(ArrayList rows, int offset, int limit)
Sort a list of rows using offset and limit.
void sort(ArrayList rows, int offset, int limit)
Sort a list of rows using offset and limit.
Parameters:
rows - the list of rows
offset - the offset
limit - the limit