Debian Codegraph @

src/main/org/h2/expression/Operation1.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.expression;
7
8 import org.h2.engine.SessionLocal;
9 import org.h2.table.ColumnResolver;
10 import org.h2.table.TableFilter;
11 import org.h2.value.TypeInfo;
12
13 /**
14 * Operation with one argument.
15 */
16 public abstract class Operation1 extends Expression {
17
18 /**
19 * The argument of the operation.
20 */
21 protected Expression arg;
22
23 /**
24 * The type of the result.
25 */
26 protected TypeInfo type;
27
28 protected Operation1(Expression arg) {
29 this.arg = arg;
30 }
31
32 @Override
33 public TypeInfo getType() {
34 return type;
35 }
36
37 @Override
38 public void mapColumns(ColumnResolver resolver, int level, int state) {
39 arg.mapColumns(resolver, level, state);
40 }
41
42 @Override
43 public void setEvaluatable(TableFilter tableFilter, boolean value) {
44 arg.setEvaluatable(tableFilter, value);
45 }
46
47 @Override
48 public void updateAggregate(SessionLocal session, int stage) {
49 arg.updateAggregate(session, stage);
50 }
51
52 @Override
53 public boolean isEverything(ExpressionVisitor visitor) {
54 return arg.isEverything(visitor);
55 }
56
57 @Override
58 public int getCost() {
59 return arg.getCost() + 1;
60 }
61
62 @Override
63 public int getSubexpressionCount() {
64 return 1;
65 }
66
67 @Override
68 public Expression getSubexpression(int index) {
69 if (index == 0) {
70 return arg;
71 }
72 throw new IndexOutOfBoundsException();
73 }
74
75 }