Source Code Cross Referenced for ConstraintDef.java in  » Database-DBMS » mckoi » com » mckoi » database » interpret » 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 » mckoi » com.mckoi.database.interpret 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * com.mckoi.database.interpret.ConstraintDef  09 Sep 2001
003:         *
004:         * Mckoi SQL Database ( http://www.mckoi.com/database )
005:         * Copyright (C) 2000, 2001, 2002  Diehl and Associates, Inc.
006:         *
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License
009:         * Version 2 as published by the Free Software Foundation.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License Version 2 for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * Version 2 along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
019:         *
020:         * Change Log:
021:         * 
022:         * 
023:         */package com.mckoi.database.interpret;
024:
025:        import com.mckoi.database.*;
026:        import java.util.ArrayList;
027:
028:        /**
029:         * Represents a constraint definition (description) for a table.
030:         *
031:         * @author Tobias Downer
032:         */
033:
034:        public final class ConstraintDef implements  java.io.Serializable,
035:                StatementTreeObject, Cloneable {
036:
037:            static final long serialVersionUID = -6648793780645431100L;
038:
039:            // ---------- Statics that represent the base types of constraints ----------
040:
041:            /**
042:             * A PRIMARY_KEY constraint.  With this constraint, the 'column_list'
043:             * list contains the names of the columns in this table that are defined as
044:             * the primary key.  There may only be one primary key constraint per table.
045:             */
046:            public static final int PRIMARY_KEY = 1;
047:
048:            /**
049:             * A UNIQUE constraint.  With this constraint, the 'column_list' list
050:             * contains the names of the columns in this table that must be unique.
051:             */
052:            public static final int UNIQUE = 2;
053:
054:            /**
055:             * A FOREIGN_KEY constraint.  With this constraint, the 'table_name' string
056:             * contains the name of the table that this is a foreign key for, the
057:             * 'column_list' list contains the list of foreign key columns, and
058:             * 'column_list2' optionally contains the referenced columns.
059:             */
060:            public static final int FOREIGN_KEY = 3;
061:
062:            /**
063:             * A CHECK constraint.  With this constraint, the 'expression' object
064:             * contains the expression that must evaluate to true when adding a
065:             * column to the table.
066:             */
067:            public static final int CHECK = 4;
068:
069:            // The type of constraint (from types in DataTableConstraintDef)
070:            int type;
071:
072:            // The name of the constraint or null if the constraint has no name (in
073:            // which case it must be given an auto generated unique name at some point).
074:            String name;
075:
076:            // The Check Expression
077:            Expression check_expression;
078:            // The serializable plain check expression as originally parsed
079:            Expression original_check_expression;
080:
081:            // The first column list
082:            ArrayList column_list;
083:
084:            // The second column list
085:            ArrayList column_list2;
086:
087:            // The name of the table if referenced.
088:            String reference_table_name;
089:
090:            // The foreign key update rule
091:            String update_rule;
092:
093:            // The foreign key delete rule
094:            String delete_rule;
095:
096:            // Whether this constraint is deferred to when the transaction commits.
097:            // ( By default we are 'initially immediate deferrable' )
098:            short deferred = Transaction.INITIALLY_IMMEDIATE;
099:
100:            public ConstraintDef() {
101:            }
102:
103:            /**
104:             * Sets the name of the constraint.
105:             */
106:            public void setName(String name) {
107:                this .name = name;
108:            }
109:
110:            /**
111:             * Sets object up for a primary key constraint.
112:             */
113:            public void setPrimaryKey(ArrayList list) {
114:                type = PRIMARY_KEY;
115:                column_list = list;
116:            }
117:
118:            /**
119:             * Sets object up for a unique constraint.
120:             */
121:            public void setUnique(ArrayList list) {
122:                type = UNIQUE;
123:                column_list = list;
124:            }
125:
126:            /**
127:             * Sets object up for a check constraint.
128:             */
129:            public void setCheck(Expression exp) {
130:                type = CHECK;
131:                check_expression = exp;
132:                try {
133:                    original_check_expression = (Expression) exp.clone();
134:                } catch (CloneNotSupportedException e) {
135:                    throw new Error(e.getMessage());
136:                }
137:            }
138:
139:            /**
140:             * Sets object up for foreign key reference.
141:             */
142:            public void setForeignKey(String ref_table, ArrayList col_list,
143:                    ArrayList ref_col_list, String delete_rule,
144:                    String update_rule) {
145:                type = FOREIGN_KEY;
146:                reference_table_name = ref_table;
147:                column_list = col_list;
148:                column_list2 = ref_col_list;
149:                this .delete_rule = delete_rule;
150:                this .update_rule = update_rule;
151:
152:                //    System.out.println("ConstraintDef setting rules: " + delete_rule + ", " + update_rule);
153:            }
154:
155:            /**
156:             * Sets that this constraint is initially deferred.
157:             */
158:            public void setInitiallyDeferred() {
159:                deferred = Transaction.INITIALLY_DEFERRED;
160:            }
161:
162:            /**
163:             * Sets that this constraint is not deferrable.
164:             */
165:            public void setNotDeferrable() {
166:                deferred = Transaction.NOT_DEFERRABLE;
167:            }
168:
169:            /**
170:             * Returns the first column list as a string array.
171:             */
172:            public String[] getColumnList() {
173:                return (String[]) column_list.toArray(new String[column_list
174:                        .size()]);
175:            }
176:
177:            /**
178:             * Returns the first column list as a string array.
179:             */
180:            public String[] getColumnList2() {
181:                return (String[]) column_list2.toArray(new String[column_list2
182:                        .size()]);
183:            }
184:
185:            /**
186:             * Returns the delete rule if this is a foreign key reference.
187:             */
188:            public String getDeleteRule() {
189:                return delete_rule;
190:            }
191:
192:            /**
193:             * Returns the update rule if this is a foreign key reference.
194:             */
195:            public String getUpdateRule() {
196:                return update_rule;
197:            }
198:
199:            // Implemented from StatementTreeObject
200:            public void prepareExpressions(ExpressionPreparer preparer)
201:                    throws DatabaseException {
202:                if (check_expression != null) {
203:                    check_expression.prepare(preparer);
204:                }
205:            }
206:
207:            public Object clone() throws CloneNotSupportedException {
208:                ConstraintDef v = (ConstraintDef) super .clone();
209:                if (check_expression != null) {
210:                    v.check_expression = (Expression) check_expression.clone();
211:                }
212:                if (column_list != null) {
213:                    v.column_list = (ArrayList) column_list.clone();
214:                }
215:                if (column_list2 != null) {
216:                    v.column_list2 = (ArrayList) column_list2.clone();
217:                }
218:                return v;
219:            }
220:
221:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.