KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > h2 > expression > Alias


1 /*
2  * Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
3  * Initial Developer: H2 Group
4  */

5 package org.h2.expression;
6
7 import java.sql.SQLException JavaDoc;
8
9 import org.h2.engine.Session;
10 import org.h2.table.ColumnResolver;
11 import org.h2.table.TableFilter;
12 import org.h2.value.Value;
13
14
15 /**
16  * @author Thomas
17  */

18
19 public class Alias extends Expression {
20
21     private Expression expr;
22     private String JavaDoc alias;
23
24     public Alias(Expression expression, String JavaDoc alias) {
25         this.expr = expression;
26         this.alias = alias;
27     }
28     
29     public Expression getNonAliasExpression() {
30         return expr;
31     }
32
33     public Value getValue(Session session) throws SQLException JavaDoc {
34         return expr.getValue(session);
35     }
36
37     public int getType() {
38         return expr.getType();
39     }
40
41     public void mapColumns(ColumnResolver resolver, int level) throws SQLException JavaDoc {
42         expr.mapColumns(resolver, level);
43     }
44
45     public Expression optimize(Session session) throws SQLException JavaDoc {
46         expr = expr.optimize(session);
47         return this;
48     }
49
50     public void setEvaluatable(TableFilter tableFilter, boolean b) {
51         expr.setEvaluatable(tableFilter, b);
52     }
53
54     public int getScale() {
55         return expr.getScale();
56     }
57
58     public long getPrecision() {
59         return expr.getPrecision();
60     }
61     
62     public boolean isAutoIncrement() {
63         return expr.isAutoIncrement();
64     }
65
66     public String JavaDoc getSQL() {
67         return expr.getSQL() + " AS " + alias;
68     }
69     
70     public void updateAggregate(Session session) throws SQLException JavaDoc {
71         expr.updateAggregate(session);
72     }
73     
74     public String JavaDoc getAlias() {
75         return alias;
76     }
77
78     public int getNullable() {
79         return expr.getNullable();
80     }
81
82     public boolean isEverything(ExpressionVisitor visitor) {
83         return expr.isEverything(visitor);
84     }
85     
86     public int getCost() {
87         return expr.getCost();
88     }
89
90 }
91
Popular Tags