Debian Codegraph @

src/main/org/h2/command/query/QueryOrderBy.java

raw
1 /*
2 * Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0,
3 * and the EPL 1.0 (https://h2database.com/html/license.html).
4 * Initial Developer: H2 Group
5 */
6 package org.h2.command.query;
7
8 import org.h2.expression.Expression;
9 import org.h2.result.SortOrder;
10
11 /**
12 * Describes one element of the ORDER BY clause of a query.
13 */
14 public class QueryOrderBy {
15
16 /**
17 * The order by expression.
18 */
19 public Expression expression;
20
21 /**
22 * The column index expression. This can be a column index number (1 meaning
23 * the first column of the select list) or a parameter (the parameter is a
24 * number representing the column index number).
25 */
26 public Expression columnIndexExpr;
27
28 /**
29 * Sort type for this column.
30 */
31 public int sortType;
32
33 /**
34 * Appends the order by expression to the specified builder.
35 *
36 * @param builder the string builder
37 * @param sqlFlags formatting flags
38 */
39 public void getSQL(StringBuilder builder, int sqlFlags) {
40 (expression != null ? expression : columnIndexExpr).getUnenclosedSQL(builder, sqlFlags);
41 SortOrder.typeToString(builder, sortType);
42 }
43
44 }