Source Code Cross Referenced for Constraint.java in  » Database-DBMS » h2database » org » h2 » constraint » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database DBMS » h2database » org.h2.constraint 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.constraint;
007:
008:        import java.sql.SQLException;
009:
010:        import org.h2.engine.DbObject;
011:        import org.h2.engine.Session;
012:        import org.h2.index.Index;
013:        import org.h2.message.Message;
014:        import org.h2.message.Trace;
015:        import org.h2.result.Row;
016:        import org.h2.schema.Schema;
017:        import org.h2.schema.SchemaObjectBase;
018:        import org.h2.table.Column;
019:        import org.h2.table.Table;
020:
021:        /**
022:         * The base class for constraint checking.
023:         */
024:        public abstract class Constraint extends SchemaObjectBase implements 
025:                Comparable {
026:
027:            /**
028:             * The constraint type name for check constraints.
029:             */
030:            public static final String CHECK = "CHECK";
031:
032:            /**
033:             * The constraint type name for referential constraints.
034:             */
035:            public static final String REFERENTIAL = "REFERENTIAL";
036:
037:            /**
038:             * The constraint type name for unique constraints.
039:             */
040:            public static final String UNIQUE = "UNIQUE";
041:
042:            /**
043:             * The constraint type name for primary key constraints.
044:             */
045:            public static final String PRIMARY_KEY = "PRIMARY KEY";
046:
047:            /**
048:             * The table for which this constraint is defined.
049:             */
050:            protected Table table;
051:
052:            /**
053:             * The constraint type name
054:             *
055:             * @return the name
056:             */
057:            public abstract String getConstraintType();
058:
059:            /**
060:             * Check if this row fulfils the constraint.
061:             * This method throws an exception if not.
062:             *
063:             * @param session the session
064:             * @param t the table
065:             * @param oldRow the old row
066:             * @param newRow the new row
067:             */
068:            public abstract void checkRow(Session session, Table t, Row oldRow,
069:                    Row newRow) throws SQLException;
070:
071:            /**
072:             * Check if this constraint needs the specified index.
073:             *
074:             * @param index the index
075:             * @return true if the index is used
076:             */
077:            public abstract boolean usesIndex(Index index);
078:
079:            /**
080:             * This index is now the owner of the specified index.
081:             *
082:             * @param index
083:             */
084:            public abstract void setIndexOwner(Index index);
085:
086:            /**
087:             * Check if this constraint contains the given column.
088:             *
089:             * @param col the column
090:             * @return true if it does
091:             */
092:            public abstract boolean containsColumn(Column col);
093:
094:            /**
095:             * Get the SQL statement to create this constraint.
096:             *
097:             * @return the SQL statement
098:             */
099:            public abstract String getCreateSQLWithoutIndexes();
100:
101:            /**
102:             * Check if this constraint needs to be checked before updating the data.
103:             *
104:             * @return true if it must be checked before updating
105:             */
106:            public abstract boolean isBefore();
107:
108:            /**
109:             * Get a short description of the constraint. This includes the constraint
110:             * name (if set), and the constraint expression.
111:             * 
112:             * @return the description
113:             */
114:            public abstract String getShortDescription();
115:
116:            /**
117:             * Check the existing data. This method is called if the constraint is added
118:             * after data has been inserted into the table.
119:             * 
120:             * @param session the session
121:             */
122:            public abstract void checkExistingData(Session session)
123:                    throws SQLException;
124:
125:            public Constraint(Schema schema, int id, String name, Table table) {
126:                super (schema, id, name, Trace.CONSTRAINT);
127:                this .table = table;
128:                this .setTemporary(table.getTemporary());
129:            }
130:
131:            public void checkRename() throws SQLException {
132:                // ok
133:            }
134:
135:            public int getType() {
136:                return DbObject.CONSTRAINT;
137:            }
138:
139:            public Table getTable() {
140:                return table;
141:            }
142:
143:            public Table getRefTable() {
144:                return table;
145:            }
146:
147:            public String getDropSQL() {
148:                return null;
149:            }
150:
151:            private int getConstraintTypeOrder() {
152:                String constraintType = getConstraintType();
153:                if (CHECK.equals(constraintType)) {
154:                    return 0;
155:                } else if (PRIMARY_KEY.equals(constraintType)) {
156:                    return 1;
157:                } else if (UNIQUE.equals(constraintType)) {
158:                    return 2;
159:                } else if (REFERENTIAL.equals(constraintType)) {
160:                    return 3;
161:                } else {
162:                    throw Message.getInternalError("type: " + constraintType);
163:                }
164:            }
165:
166:            public int compareTo(Object other) {
167:                if (this  == other) {
168:                    return 0;
169:                }
170:                Constraint otherConstraint = (Constraint) other;
171:                int this Type = getConstraintTypeOrder();
172:                int otherType = otherConstraint.getConstraintTypeOrder();
173:                return thisType - otherType;
174:            }
175:
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.