org.h2.engine
Class DbObjectBase

java.lang.Object
  extended by org.h2.engine.DbObjectBase
All Implemented Interfaces:
DbObject
Direct Known Subclasses:
Comment, Right, RightOwner, Schema, SchemaObjectBase, Setting, UserAggregate, UserDataType

public abstract class DbObjectBase
extends java.lang.Object
implements DbObject

The base class for all database objects.


Field Summary
protected  java.lang.String comment
          The comment (if set).
protected  Database database
          The database.
protected  Trace trace
          The trace module.
 
Fields inherited from interface org.h2.engine.DbObject
AGGREGATE, COMMENT, CONSTANT, CONSTRAINT, FUNCTION_ALIAS, INDEX, RIGHT, ROLE, SCHEMA, SEQUENCE, SETTING, TABLE_OR_VIEW, TRIGGER, USER, USER_DATATYPE
 
Constructor Summary
DbObjectBase()
           
 
Method Summary
abstract  void checkRename()
          Check if this object can be renamed.
 java.util.ArrayList<DbObject> getChildren()
          Get the list of dependent children (for tables, this includes indexes and so on).
 java.lang.String getComment()
          Get the current comment of this object.
abstract  java.lang.String getCreateSQL()
          Build a SQL statement to re-create this object.
abstract  java.lang.String getCreateSQLForCopy(Table table, java.lang.String quotedName)
          Build a SQL statement to re-create the object, or to create a copy of the object with a different name or referencing a different table
 Database getDatabase()
          Get the database.
abstract  java.lang.String getDropSQL()
          Build a SQL statement to drop this object.
 int getId()
          Get the unique object id.
 long getModificationId()
          Get the last modification id.
 java.lang.String getName()
          Get the name.
 java.lang.String getSQL()
          Get the SQL name of this object (may be quoted).
abstract  int getType()
          Get the object type.
protected  void initDbObjectBase(Database db, int objectId, java.lang.String name, java.lang.String traceModule)
          Initialize some attributes of this object.
protected  void invalidate()
          Set the main attributes to null to make sure the object is no longer used.
 boolean isTemporary()
          Check if this object is temporary (for example, a temporary table).
abstract  void removeChildrenAndResources(Session session)
          Remove all dependent objects and free all resources (files, blocks in files) of this object.
 void rename(java.lang.String newName)
          Rename the object.
 void setComment(java.lang.String comment)
          Change the comment of this object.
 void setModified()
          Tell the object that is was modified.
protected  void setObjectName(java.lang.String name)
           
 void setTemporary(boolean temporary)
          Tell this object that it is temporary or not.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

database

protected Database database
The database.


trace

protected Trace trace
The trace module.


comment

protected java.lang.String comment
The comment (if set).

Constructor Detail

DbObjectBase

public DbObjectBase()
Method Detail

initDbObjectBase

protected void initDbObjectBase(Database db,
                                int objectId,
                                java.lang.String name,
                                java.lang.String traceModule)
Initialize some attributes of this object.

Parameters:
db - the database
objectId - the object id
name - the name
traceModule - the trace module name

getCreateSQLForCopy

public abstract java.lang.String getCreateSQLForCopy(Table table,
                                                     java.lang.String quotedName)
Build a SQL statement to re-create the object, or to create a copy of the object with a different name or referencing a different table

Specified by:
getCreateSQLForCopy in interface DbObject
Parameters:
table - the new table name
quotedName - the new quoted name
Returns:
the SQL statement

getCreateSQL

public abstract java.lang.String getCreateSQL()
Build a SQL statement to re-create this object.

Specified by:
getCreateSQL in interface DbObject
Returns:
the SQL statement

getDropSQL

public abstract java.lang.String getDropSQL()
Build a SQL statement to drop this object.

Specified by:
getDropSQL in interface DbObject
Returns:
the SQL statement

getType

public abstract int getType()
Get the object type.

Specified by:
getType in interface DbObject
Returns:
the object type

removeChildrenAndResources

public abstract void removeChildrenAndResources(Session session)
Remove all dependent objects and free all resources (files, blocks in files) of this object.

Specified by:
removeChildrenAndResources in interface DbObject
Parameters:
session - the session

checkRename

public abstract void checkRename()
Check if this object can be renamed. System objects may not be renamed.

Specified by:
checkRename in interface DbObject

setModified

public void setModified()
Description copied from interface: DbObject
Tell the object that is was modified.

Specified by:
setModified in interface DbObject

getModificationId

public long getModificationId()
Description copied from interface: DbObject
Get the last modification id.

Specified by:
getModificationId in interface DbObject
Returns:
the modification id

setObjectName

protected void setObjectName(java.lang.String name)

getSQL

public java.lang.String getSQL()
Description copied from interface: DbObject
Get the SQL name of this object (may be quoted).

Specified by:
getSQL in interface DbObject
Returns:
the SQL name

getChildren

public java.util.ArrayList<DbObject> getChildren()
Description copied from interface: DbObject
Get the list of dependent children (for tables, this includes indexes and so on).

Specified by:
getChildren in interface DbObject
Returns:
the list of children

getDatabase

public Database getDatabase()
Description copied from interface: DbObject
Get the database.

Specified by:
getDatabase in interface DbObject
Returns:
the database

getId

public int getId()
Description copied from interface: DbObject
Get the unique object id.

Specified by:
getId in interface DbObject
Returns:
the object id

getName

public java.lang.String getName()
Description copied from interface: DbObject
Get the name.

Specified by:
getName in interface DbObject
Returns:
the name

invalidate

protected void invalidate()
Set the main attributes to null to make sure the object is no longer used.


rename

public void rename(java.lang.String newName)
Description copied from interface: DbObject
Rename the object.

Specified by:
rename in interface DbObject
Parameters:
newName - the new name

isTemporary

public boolean isTemporary()
Description copied from interface: DbObject
Check if this object is temporary (for example, a temporary table).

Specified by:
isTemporary in interface DbObject
Returns:
true if is temporary

setTemporary

public void setTemporary(boolean temporary)
Description copied from interface: DbObject
Tell this object that it is temporary or not.

Specified by:
setTemporary in interface DbObject
Parameters:
temporary - the new value

setComment

public void setComment(java.lang.String comment)
Description copied from interface: DbObject
Change the comment of this object.

Specified by:
setComment in interface DbObject
Parameters:
comment - the new comment, or null for no comment

getComment

public java.lang.String getComment()
Description copied from interface: DbObject
Get the current comment of this object.

Specified by:
getComment in interface DbObject
Returns:
the comment, or null if not set

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object