KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > h2 > schema > Constant


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.schema;
6
7 import java.sql.SQLException JavaDoc;
8
9 import org.h2.engine.DbObject;
10 import org.h2.engine.Session;
11 import org.h2.expression.ValueExpression;
12 import org.h2.message.Message;
13 import org.h2.message.Trace;
14 import org.h2.table.Table;
15 import org.h2.value.Value;
16
17 public class Constant extends SchemaObject {
18     
19     private Value value;
20     private ValueExpression expression;
21     
22     public Constant(Schema schema, int id, String JavaDoc name) {
23         super(schema, id, name, Trace.SCHEMA);
24     }
25
26     public String JavaDoc getCreateSQLForCopy(Table table, String JavaDoc quotedName) {
27         throw Message.getInternalError();
28     }
29
30     public String JavaDoc getCreateSQL() {
31         StringBuffer JavaDoc buff = new StringBuffer JavaDoc();
32         buff.append("CREATE CONSTANT ");
33         buff.append(getSQL());
34         buff.append(" VALUE ");
35         buff.append(value.getSQL());
36         return buff.toString();
37     }
38
39     public int getType() {
40         return DbObject.CONSTANT;
41     }
42
43     public void removeChildrenAndResources(Session session) throws SQLException JavaDoc {
44         invalidate();
45     }
46
47     public void checkRename() throws SQLException JavaDoc {
48     }
49
50     public void setValue(Value value) {
51         this.value = value;
52         expression = ValueExpression.get(value);
53     }
54
55     public ValueExpression getValue() {
56         return expression;
57     }
58
59 }
60
Popular Tags