Debian Codegraph @

src/main/org/h2/schema/SchemaObject.java

raw
1 /*
2 * Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0,
3 * and the EPL 1.0 (https://h2database.com/html/license.html).
4 * Initial Developer: H2 Group
5 */
6 package org.h2.schema;
7
8 import org.h2.engine.DbObject;
9
10 /**
11 * Any database object that is stored in a schema.
12 */
13 public abstract class SchemaObject extends DbObject {
14
15 private final Schema schema;
16
17 /**
18 * Initialize some attributes of this object.
19 *
20 * @param newSchema the schema
21 * @param id the object id
22 * @param name the name
23 * @param traceModuleId the trace module id
24 */
25 protected SchemaObject(Schema newSchema, int id, String name, int traceModuleId) {
26 super(newSchema.getDatabase(), id, name, traceModuleId);
27 this.schema = newSchema;
28 }
29
30 /**
31 * Get the schema in which this object is defined
32 *
33 * @return the schema
34 */
35 public final Schema getSchema() {
36 return schema;
37 }
38
39 @Override
40 public String getSQL(int sqlFlags) {
41 return getSQL(new StringBuilder(), sqlFlags).toString();
42 }
43
44 @Override
45 public StringBuilder getSQL(StringBuilder builder, int sqlFlags) {
46 schema.getSQL(builder, sqlFlags).append('.');
47 return super.getSQL(builder, sqlFlags);
48 }
49
50 /**
51 * Check whether this is a hidden object that doesn't appear in the meta
52 * data and in the script, and is not dropped on DROP ALL OBJECTS.
53 *
54 * @return true if it is hidden
55 */
56 public boolean isHidden() {
57 return false;
58 }
59
60 }