KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > h2 > constraint > Constraint


1 /*
2  * Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
3  * Initial Developer: H2 Group
4  */

5 package org.h2.constraint;
6
7 import java.sql.SQLException JavaDoc;
8
9 import org.h2.engine.DbObject;
10 import org.h2.engine.Session;
11 import org.h2.index.Index;
12 import org.h2.message.Trace;
13 import org.h2.result.Row;
14 import org.h2.schema.Schema;
15 import org.h2.schema.SchemaObject;
16 import org.h2.table.Column;
17 import org.h2.table.Table;
18
19 /**
20  * @author Thomas
21  */

22 public abstract class Constraint extends SchemaObject {
23     
24     protected Table table;
25     public static final String JavaDoc CHECK = "CHECK", REFERENTIAL = "REFERENTIAL", UNIQUE = "UNIQUE";
26     
27     public Constraint(Schema schema, int id, String JavaDoc name, Table table) {
28         super(schema, id, name, Trace.CONSTRAINT);
29         this.table = table;
30         this.setTemporary(table.getTemporary());
31     }
32     
33     public void checkRename() throws SQLException JavaDoc {
34         // ok
35
}
36
37     public int getType() {
38         return DbObject.CONSTRAINT;
39     }
40     
41     public abstract String JavaDoc getConstraintType();
42     public abstract void checkRow(Session session, Table t, Row oldRow, Row newRow) throws SQLException JavaDoc;
43     public abstract boolean usesIndex(Index index);
44     public abstract boolean containsColumn(Column col);
45     public abstract String JavaDoc getCreateSQLWithoutIndexes();
46     public abstract boolean isBefore();
47     public abstract String JavaDoc getShortDescription();
48     
49     public Table getTable() {
50         return table;
51     }
52     
53     public Table getRefTable() {
54         return table;
55     }
56
57 }
58
Popular Tags