1 5 package org.h2.constraint; 6 7 import java.sql.SQLException ; 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 22 public abstract class Constraint extends SchemaObject { 23 24 protected Table table; 25 public static final String CHECK = "CHECK", REFERENTIAL = "REFERENTIAL", UNIQUE = "UNIQUE"; 26 27 public Constraint(Schema schema, int id, String 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 { 34 } 36 37 public int getType() { 38 return DbObject.CONSTRAINT; 39 } 40 41 public abstract String getConstraintType(); 42 public abstract void checkRow(Session session, Table t, Row oldRow, Row newRow) throws SQLException ; 43 public abstract boolean usesIndex(Index index); 44 public abstract boolean containsColumn(Column col); 45 public abstract String getCreateSQLWithoutIndexes(); 46 public abstract boolean isBefore(); 47 public abstract String getShortDescription(); 48 49 public Table getTable() { 50 return table; 51 } 52 53 public Table getRefTable() { 54 return table; 55 } 56 57 } 58 | Popular Tags |