File D:\maven-qcr-plugin-testsunitaires\qcr4java\h2-1.3.170-sources\target\site\qc\lecode\schema\Constant.java.html

1 /*
2 * Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License,
3 * Version 1.0, and under the Eclipse Public License, Version 1.0
4 * (http://h2database.com/html/license.html).
5 * Initial Developer: H2 Group
6 */
7 package org.h2.schema;
8
9 import org.h2.engine.DbObject;
10 import org.h2.engine.Session;
11 import org.h2.expression.ValueExpression;
12 import org.h2.message.DbException;
13 import org.h2.message.Trace;
14 import org.h2.table.Table;
15 import org.h2.value.Value;
16
17 /**
18 * A user-defined constant as created by the SQL statement
19 * CREATE CONSTANT
20 */
21 public class Constant extends SchemaObjectBase {
22
23 private Value value;
24 private ValueExpression expression;
25
26 public Constant(Schema schema, int id, String name) {
27 initSchemaObjectBase(schema, id, name, Trace.SCHEMA);
28 }
29
30 public String getCreateSQLForCopy(Table table, String quotedName) {
31 throw DbException.throwInternalError();
32 }
33
34 public String getDropSQL() {
35 return null;
36 }
37
38 public String getCreateSQL() {
39 return "CREATE CONSTANT " + getSQL() + " VALUE " + value.getSQL();
40 }
41
42 public int getType() {
43 return DbObject.CONSTANT;
44 }
45
46 public void removeChildrenAndResources(Session session) {
47 database.removeMeta(session, getId());
48 invalidate();
49 }
50
51 public void checkRename() {
52 // ok
53 }
54
55 public void setValue(Value value) {
56 this.value = value;
57 expression = ValueExpression.get(value);
58 }
59
60 public ValueExpression getValue() {
61 return expression;
62 }
63
64 }
65