01: /*
02: * Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
03: * (http://h2database.com/html/license.html).
04: * Initial Developer: H2 Group
05: */
06: package org.h2.engine;
07:
08: import java.sql.SQLException;
09:
10: import org.h2.message.Message;
11: import org.h2.message.Trace;
12: import org.h2.table.Column;
13: import org.h2.table.Table;
14:
15: /**
16: * Represents a domain (user defined data type).
17: */
18: public class UserDataType extends DbObjectBase {
19:
20: private Column column;
21:
22: public UserDataType(Database database, int id, String name) {
23: super (database, id, name, Trace.DATABASE);
24: }
25:
26: public String getCreateSQLForCopy(Table table, String quotedName) {
27: throw Message.getInternalError();
28: }
29:
30: public String getDropSQL() {
31: return "DROP DOMAIN IF EXISTS " + getSQL();
32: }
33:
34: public String getCreateSQL() {
35: StringBuffer buff = new StringBuffer();
36: buff.append("CREATE DOMAIN ");
37: buff.append(getSQL());
38: buff.append(" AS ");
39: buff.append(column.getCreateSQL());
40: return buff.toString();
41: }
42:
43: public Column getColumn() {
44: return column;
45: }
46:
47: public int getType() {
48: return DbObject.USER_DATATYPE;
49: }
50:
51: public void removeChildrenAndResources(Session session)
52: throws SQLException {
53: database.removeMeta(session, getId());
54: }
55:
56: public void checkRename() throws SQLException {
57: }
58:
59: public void setColumn(Column column) {
60: this.column = column;
61: }
62:
63: }
|