Debian Codegraph @

src/main/org/h2/table/ColumnResolver.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.table;
7
8 import org.h2.command.query.Select;
9 import org.h2.expression.Expression;
10 import org.h2.expression.ExpressionColumn;
11 import org.h2.value.Value;
12
13 /**
14 * A column resolver is list of column (for example, a table) that can map a
15 * column name to an actual column.
16 */
17 public interface ColumnResolver {
18
19 /**
20 * Get the table alias.
21 *
22 * @return the table alias
23 */
24 default String getTableAlias() {
25 return null;
26 }
27
28 /**
29 * Get the column list.
30 *
31 * @return the column list
32 */
33 Column[] getColumns();
34
35 /**
36 * Get the column with the specified name.
37 *
38 * @param name
39 * the column name, must be a derived name if this column
40 * resolver has a derived column list
41 * @return the column with the specified name, or {@code null}
42 */
43 Column findColumn(String name);
44
45 /**
46 * Get the name of the specified column.
47 *
48 * @param column column
49 * @return column name
50 */
51 default String getColumnName(Column column) {
52 return column.getName();
53 }
54
55 /**
56 * Returns whether this column resolver has a derived column list.
57 *
58 * @return {@code true} if this column resolver has a derived column list,
59 * {@code false} otherwise
60 */
61 default boolean hasDerivedColumnList() {
62 return false;
63 }
64
65 /**
66 * Get the list of system columns, if any.
67 *
68 * @return the system columns or null
69 */
70 default Column[] getSystemColumns() {
71 return null;
72 }
73
74 /**
75 * Get the row id pseudo column, if there is one.
76 *
77 * @return the row id column or null
78 */
79 default Column getRowIdColumn() {
80 return null;
81 }
82
83 /**
84 * Get the schema name or null.
85 *
86 * @return the schema name or null
87 */
88 default String getSchemaName() {
89 return null;
90 }
91
92 /**
93 * Get the value for the given column.
94 *
95 * @param column the column
96 * @return the value
97 */
98 Value getValue(Column column);
99
100 /**
101 * Get the table filter.
102 *
103 * @return the table filter
104 */
105 default TableFilter getTableFilter() {
106 return null;
107 }
108
109 /**
110 * Get the select statement.
111 *
112 * @return the select statement
113 */
114 default Select getSelect() {
115 return null;
116 }
117
118 /**
119 * Get the expression that represents this column.
120 *
121 * @param expressionColumn the expression column
122 * @param column the column
123 * @return the optimized expression
124 */
125 default Expression optimize(ExpressionColumn expressionColumn, Column column) {
126 return expressionColumn;
127 }
128
129 }