001: /*
002: * Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
003: * (http://h2database.com/html/license.html).
004: * Initial Developer: H2 Group
005: */
006: package org.h2.engine;
007:
008: import java.sql.SQLException;
009: import org.h2.table.Table;
010: import org.h2.util.ObjectArray;
011:
012: /**
013: * A database object such as a table, an index, or a user.
014: */
015: public interface DbObject {
016:
017: /**
018: * The object is of the type table or view.
019: */
020: int TABLE_OR_VIEW = 0;
021:
022: /**
023: * This object is an index.
024: */
025: int INDEX = 1;
026:
027: /**
028: * This object is a user.
029: */
030: int USER = 2;
031:
032: /**
033: * This object is a sequence.
034: */
035: int SEQUENCE = 3;
036:
037: /**
038: * This object is a trigger.
039: */
040: int TRIGGER = 4;
041:
042: /**
043: * This object is a constraint (check constraint, unique constraint, or
044: * referential constraint).
045: */
046: int CONSTRAINT = 5;
047:
048: /**
049: * This object is a setting.
050: */
051: int SETTING = 6;
052:
053: /**
054: * This object is a role.
055: */
056: int ROLE = 7;
057:
058: /**
059: * This object is a right.
060: */
061: int RIGHT = 8;
062:
063: /**
064: * This object is an alias for a Java function.
065: */
066: int FUNCTION_ALIAS = 9;
067:
068: /**
069: * This object is a schema.
070: */
071: int SCHEMA = 10;
072:
073: /**
074: * This object is a constant.
075: */
076: int CONSTANT = 11;
077:
078: /**
079: * This object is a user data type (domain).
080: */
081: int USER_DATATYPE = 12;
082:
083: /**
084: * This object is a comment.
085: */
086: int COMMENT = 13;
087:
088: /**
089: * This object is a user defined aggregate function.
090: */
091: int AGGREGATE = 14;
092:
093: /**
094: * Tell the object that is was modified.
095: */
096: void setModified();
097:
098: /**
099: * Get the last modification id.
100: *
101: * @return the modification id
102: */
103: long getModificationId();
104:
105: /**
106: * Get the SQL name of this object (may be quoted).
107: *
108: * @return the SQL name
109: */
110: String getSQL();
111:
112: /**
113: * Get the list of dependent children (for tables, this includes indexes and
114: * so on).
115: *
116: * @return the list of children
117: */
118: ObjectArray getChildren();
119:
120: /**
121: * Get the database.
122: *
123: * @return the database
124: */
125: Database getDatabase();
126:
127: /**
128: * Get the unique object id.
129: *
130: * @return the object id
131: */
132: int getId();
133:
134: /**
135: * Get the name.
136: *
137: * @return the name
138: */
139: String getName();
140:
141: /**
142: * Construct a CREATE ... SQL statement for this object when creating a copy
143: * of it.
144: *
145: * @param table the new table
146: * @param quotedName the quoted name
147: * @return the SQL statement
148: */
149: String getCreateSQLForCopy(Table table, String quotedName);
150:
151: /**
152: * Construct the original CREATE ... SQL statement for this object.
153: *
154: * @return the SQL statement
155: */
156: String getCreateSQL();
157:
158: /**
159: * Construct a DROP ... SQL statement for this object.
160: *
161: * @return the SQL statement
162: */
163: String getDropSQL();
164:
165: /**
166: * Get the object type.
167: *
168: * @return the object type
169: */
170: int getType();
171:
172: /**
173: * Delete all dependent children objects and resources of this object.
174: *
175: * @param session the session
176: */
177: void removeChildrenAndResources(Session session)
178: throws SQLException;
179:
180: /**
181: * Check if renaming is allowed. Does nothing when allowed.
182: *
183: * @throws SQLException if renaming is not allowed
184: */
185: void checkRename() throws SQLException;
186:
187: /**
188: * Rename the object.
189: *
190: * @param newName the new name
191: */
192: void rename(String newName) throws SQLException;
193:
194: /**
195: * Check if this object is temporary (for example, a temporary table).
196: *
197: * @return true if is temporary
198: */
199: boolean getTemporary();
200:
201: /**
202: * Tell this object that it is temporary or not.
203: *
204: * @param temporary the new value
205: */
206: void setTemporary(boolean temporary);
207:
208: /**
209: * Change the comment of this object.
210: *
211: * @param comment the new comment, or null for no comment
212: */
213: void setComment(String comment);
214:
215: /**
216: * Get the current comment of this object.
217: *
218: * @return the comment, or null if not set
219: */
220: String getComment();
221:
222: /**
223: * Get the position of the head record.
224: *
225: * @return the head position
226: */
227: int getHeadPos();
228: }
|