Source Code Cross Referenced for DataDescriptorGenerator.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » iapi » sql » dictionary » 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 » db derby 10.2 » org.apache.derby.iapi.sql.dictionary 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Derby - Class org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator
004:
005:           Licensed to the Apache Software Foundation (ASF) under one or more
006:           contributor license agreements.  See the NOTICE file distributed with
007:           this work for additional information regarding copyright ownership.
008:           The ASF licenses this file to you under the Apache License, Version 2.0
009:           (the "License"); you may not use this file except in compliance with
010:           the License.  You may obtain a copy of the License at
011:
012:              http://www.apache.org/licenses/LICENSE-2.0
013:
014:           Unless required by applicable law or agreed to in writing, software
015:           distributed under the License is distributed on an "AS IS" BASIS,
016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:           See the License for the specific language governing permissions and
018:           limitations under the License.
019:
020:         */
021:
022:        package org.apache.derby.iapi.sql.dictionary;
023:
024:        import org.apache.derby.iapi.services.monitor.Monitor;
025:        import org.apache.derby.iapi.error.StandardException;
026:
027:        import org.apache.derby.iapi.sql.dictionary.*;
028:
029:        import org.apache.derby.iapi.types.TypeId;
030:        import org.apache.derby.iapi.sql.depend.Dependent;
031:        import org.apache.derby.iapi.sql.depend.Provider;
032:        import org.apache.derby.iapi.reference.SQLState;
033:        import org.apache.derby.iapi.sql.execute.ConstantAction;
034:        import org.apache.derby.iapi.sql.execute.ExecPreparedStatement;
035:        import org.apache.derby.iapi.services.uuid.UUIDFactory;
036:        import org.apache.derby.iapi.services.io.FormatableBitSet;
037:
038:        import org.apache.derby.catalog.AliasInfo;
039:        import org.apache.derby.catalog.DefaultInfo;
040:        import org.apache.derby.catalog.Dependable;
041:        import org.apache.derby.catalog.DependableFinder;
042:        import org.apache.derby.catalog.ReferencedColumns;
043:        import org.apache.derby.catalog.types.ReferencedColumnsDescriptorImpl;
044:        import org.apache.derby.catalog.UUID;
045:        import org.apache.derby.catalog.Statistics;
046:        import java.sql.Timestamp;
047:        import java.io.InputStream;
048:
049:        /**
050:         * This is an implementation of the DataDescriptorGenerator interface
051:         * that lives in the DataDictionary protocol.  See that interface for
052:         * a description of what this class is supposed to do.
053:         *
054:         * @version 0.1
055:         * @author Jeff Lichtman
056:         */
057:
058:        public class DataDescriptorGenerator {
059:            private UUIDFactory uuidf;
060:
061:            protected final DataDictionary dataDictionary; // the data dictionary that this generator operates on
062:
063:            /**
064:             *	Make a generator. Specify the data dictionary that it operates on.
065:             *
066:             *	@param	dataDictionary	the data dictionary that this generator makes objects for
067:             */
068:            public DataDescriptorGenerator(DataDictionary dataDictionary) {
069:                this .dataDictionary = dataDictionary;
070:            }
071:
072:            /**
073:             * Create a descriptor for the named schema with a null UUID. 
074:             *
075:             * @param schemaName	The name of the schema we're interested in.
076:             *			If the name is NULL, get the descriptor for the
077:             *			current schema.
078:             * @param aid	The authorization ID associated with the schema.
079:             *		The owner of the schema.
080:             *
081:             * @param oid	The object ID 
082:             *
083:             * @return	The descriptor for the schema.
084:             * @exception StandardException		Thrown on failure
085:             */
086:            public SchemaDescriptor newSchemaDescriptor(String schemaName,
087:                    String aid, UUID oid) throws StandardException {
088:                return new SchemaDescriptor(dataDictionary, schemaName, aid,
089:                        oid, dataDictionary.isSystemSchemaName(schemaName));
090:            }
091:
092:            /**
093:             * Create a descriptor for the named table within the given schema.
094:             * If the schema parameter is NULL, it creates a schema descriptor
095:             * using the current default schema.
096:             *
097:             * @param tableName	The name of the table to get the descriptor for
098:             * @param schema	The descriptor for the schema the table lives in.
099:             *			If null, use the current (default) schema.
100:             * @param tableType	The type of the table: base table or view.
101:             * @param lockGranularity	The lock granularity.
102:             *
103:             * @return	The descriptor for the table.
104:             */
105:            public TableDescriptor newTableDescriptor(String tableName,
106:                    SchemaDescriptor schema, int tableType, char lockGranularity) {
107:                return new TableDescriptor(dataDictionary, tableName, schema,
108:                        tableType, lockGranularity);
109:            }
110:
111:            /**
112:             * Create a descriptor for the temporary table within the given schema.
113:             *
114:             * @param tableName	The name of the temporary table to get the descriptor for
115:             * @param schema	The descriptor for the schema the table lives in.
116:             * @param tableType	The type of the table: temporary table
117:             * @param onCommitDeleteRows	If true, on commit delete rows else on commit preserve rows of temporary table.
118:             * @param onRollbackDeleteRows	If true, on rollback, delete rows from temp tables which were logically modified. true is the only supported value
119:             *
120:             * @return	The descriptor for the table.
121:             */
122:            public TableDescriptor newTableDescriptor(String tableName,
123:                    SchemaDescriptor schema, int tableType,
124:                    boolean onCommitDeleteRows, boolean onRollbackDeleteRows) {
125:                return new TableDescriptor(dataDictionary, tableName, schema,
126:                        tableType, onCommitDeleteRows, onRollbackDeleteRows);
127:            }
128:
129:            /**
130:             * Create a viewDescriptor for the view with the given UUID.
131:             *
132:             * @param viewID	the UUID for the view.
133:             * @param viewName	the name of the view
134:             * @param viewText	the text of the view's query.
135:             * @param checkOption	int for check option type 
136:             * @param compSchemaId	the UUID of the schema this was compiled in
137:             *
138:             * @return	A descriptor for the view
139:             */
140:            public ViewDescriptor newViewDescriptor(UUID viewID,
141:                    String viewName, String viewText, int checkOption,
142:                    UUID compSchemaId) {
143:                return new ViewDescriptor(dataDictionary, viewID, viewName,
144:                        viewText, checkOption, compSchemaId);
145:            }
146:
147:            /**
148:             * @see DataDescriptorGenerator#newUniqueConstraintDescriptor
149:             */
150:            public ReferencedKeyConstraintDescriptor newUniqueConstraintDescriptor(
151:                    TableDescriptor table, String constraintName,
152:                    boolean deferrable, boolean initiallyDeferred,
153:                    int[] referencedColumns, UUID constraintId, UUID indexId,
154:                    SchemaDescriptor schemaDesc, boolean isEnabled,
155:                    int referenceCount) {
156:                return new ReferencedKeyConstraintDescriptor(
157:                        DataDictionary.UNIQUE_CONSTRAINT, dataDictionary,
158:                        table, constraintName, deferrable, initiallyDeferred,
159:                        referencedColumns, constraintId, indexId, schemaDesc,
160:                        isEnabled, referenceCount);
161:            }
162:
163:            /**
164:             * @see DataDescriptorGenerator#newPrimaryKeyConstraintDescriptor
165:             */
166:            public ReferencedKeyConstraintDescriptor newPrimaryKeyConstraintDescriptor(
167:                    TableDescriptor table, String constraintName,
168:                    boolean deferrable, boolean initiallyDeferred,
169:                    int[] referencedColumns, UUID constraintId, UUID indexId,
170:                    SchemaDescriptor schemaDesc, boolean isEnabled,
171:                    int referenceCount) {
172:                return new ReferencedKeyConstraintDescriptor(
173:                        DataDictionary.PRIMARYKEY_CONSTRAINT, dataDictionary,
174:                        table, constraintName, deferrable, initiallyDeferred,
175:                        referencedColumns, constraintId, indexId, schemaDesc,
176:                        isEnabled, referenceCount);
177:            }
178:
179:            /**
180:             * @see DataDescriptorGenerator#newForeignKeyConstraintDescriptor
181:             */
182:            public ForeignKeyConstraintDescriptor newForeignKeyConstraintDescriptor(
183:                    TableDescriptor table,
184:                    String constraintName,
185:                    boolean deferrable,
186:                    boolean initiallyDeferred,
187:                    int[] fkColumns,
188:                    UUID constraintId,
189:                    UUID indexId,
190:                    SchemaDescriptor schemaDesc,
191:                    ReferencedKeyConstraintDescriptor referencedConstraintDescriptor,
192:                    boolean isEnabled, int raDeleteRule, int raUpdateRule) {
193:                return new ForeignKeyConstraintDescriptor(dataDictionary,
194:                        table, constraintName, deferrable, initiallyDeferred,
195:                        fkColumns, constraintId, indexId, schemaDesc,
196:                        referencedConstraintDescriptor, isEnabled,
197:                        raDeleteRule, raUpdateRule);
198:            }
199:
200:            /**
201:             * @see DataDescriptorGenerator#newForeignKeyConstraintDescriptor
202:             */
203:            public ForeignKeyConstraintDescriptor newForeignKeyConstraintDescriptor(
204:                    TableDescriptor table, String constraintName,
205:                    boolean deferrable, boolean initiallyDeferred,
206:                    int[] fkColumns, UUID constraintId, UUID indexId,
207:                    SchemaDescriptor schemaDesc, UUID referencedConstraintId,
208:                    boolean isEnabled, int raDeleteRule, int raUpdateRule) {
209:                return new ForeignKeyConstraintDescriptor(dataDictionary,
210:                        table, constraintName, deferrable, initiallyDeferred,
211:                        fkColumns, constraintId, indexId, schemaDesc,
212:                        referencedConstraintId, isEnabled, raDeleteRule,
213:                        raUpdateRule);
214:            }
215:
216:            /**
217:             * @see DataDescriptorGenerator#newCheckConstraintDescriptor
218:             */
219:            public CheckConstraintDescriptor newCheckConstraintDescriptor(
220:                    TableDescriptor table, String constraintName,
221:                    boolean deferrable, boolean initiallyDeferred,
222:                    UUID constraintId, String constraintText,
223:                    ReferencedColumns referencedColumns,
224:                    SchemaDescriptor schemaDesc, boolean isEnabled) {
225:                return new CheckConstraintDescriptor(dataDictionary, table,
226:                        constraintName, deferrable, initiallyDeferred,
227:                        constraintId, constraintText, referencedColumns,
228:                        schemaDesc, isEnabled);
229:            }
230:
231:            public CheckConstraintDescriptor newCheckConstraintDescriptor(
232:                    TableDescriptor table, String constraintName,
233:                    boolean deferrable, boolean initiallyDeferred,
234:                    UUID constraintId, String constraintText, int[] refCols,
235:                    SchemaDescriptor schemaDesc, boolean isEnabled) {
236:                ReferencedColumns referencedColumns = new ReferencedColumnsDescriptorImpl(
237:                        refCols);
238:                return new CheckConstraintDescriptor(dataDictionary, table,
239:                        constraintName, deferrable, initiallyDeferred,
240:                        constraintId, constraintText, referencedColumns,
241:                        schemaDesc, isEnabled);
242:            }
243:
244:            /**
245:             * Create a conglomerate descriptor for the given conglomerate id.
246:             *
247:             * @param conglomerateId	The identifier for the conglomerate
248:             *				we're interested in
249:             * @param name			The name of the conglomerate, if any
250:             * @param indexable		TRUE means the conglomerate is indexable,
251:             *				FALSE means it isn't
252:             * @param indexRowGenerator	The IndexRowGenerator for the conglomerate,
253:             *							null if it's a heap
254:             * @param isConstraint	TRUE means the conglomerate is an index backing 
255:             *						up a constraint, FALSE means it isn't
256:             *
257:             * @param uuid	UUID  for this conglomerate
258:             * @param tableID	UUID for the table that this conglomerate belongs to
259:             * @param schemaID	UUID for the schema that conglomerate belongs to
260:             *
261:             * @return	A ConglomerateDescriptor describing the 
262:             *		conglomerate. 
263:             */
264:            public ConglomerateDescriptor newConglomerateDescriptor(
265:                    long conglomerateId, String name, boolean indexable,
266:                    IndexRowGenerator indexRowGenerator, boolean isConstraint,
267:                    UUID uuid, UUID tableID, UUID schemaID) {
268:                return (ConglomerateDescriptor) new ConglomerateDescriptor(
269:                        dataDictionary, conglomerateId, name, indexable,
270:                        indexRowGenerator, isConstraint, uuid, tableID,
271:                        schemaID);
272:            }
273:
274:            /**
275:             * Create a new trigger descriptor.
276:             *
277:             * @param sd	the schema descriptor for this trigger
278:             * @param uuid	the trigger id
279:             * @param name	the trigger name
280:             * @param eventMask	TriggerDescriptor.TRIGGER_EVENT_XXXX
281:             * @param isBefore	is this a before (as opposed to after) trigger 
282:             * @param isRow		is this a row trigger or statement trigger
283:             * @param isEnabled	is this trigger enabled or disabled
284:             * @param td		the table upon which this trigger is defined
285:             * @param whenSPSId	the sps id for the when clause (may be null)
286:             * @param actionSPSId	the spsid for the trigger action (may be null)
287:             * @param creationTimestamp	when was this trigger created?
288:             * @param referencedCols	what columns does this trigger reference (may be null)
289:             * @param triggerDefinition The original user text of the trigger action
290:             * @param referencingOld whether or not OLD appears in REFERENCING clause
291:             * @param referencingNew whether or not NEW appears in REFERENCING clause
292:             * @param oldReferencingName old referencing table name, if any, that appears in REFERCING clause
293:             * @param newReferencingName new referencing table name, if any, that appears in REFERCING clause
294:             *
295:             * @exception StandardException on error
296:             */
297:            public TriggerDescriptor newTriggerDescriptor(SchemaDescriptor sd,
298:                    UUID uuid, String name, int eventMask, boolean isBefore,
299:                    boolean isRow, boolean isEnabled, TableDescriptor td,
300:                    UUID whenSPSId, UUID actionSPSId,
301:                    Timestamp creationTimestamp, int[] referencedCols,
302:                    String triggerDefinition, boolean referencingOld,
303:                    boolean referencingNew, String oldReferencingName,
304:                    String newReferencingName) throws StandardException {
305:                return new TriggerDescriptor(dataDictionary, sd, uuid, name,
306:                        eventMask, isBefore, isRow, isEnabled, td, whenSPSId,
307:                        actionSPSId, creationTimestamp, referencedCols,
308:                        triggerDefinition, referencingOld, referencingNew,
309:                        oldReferencingName, newReferencingName);
310:            }
311:
312:            /*
313:              get a UUIDFactory. This uses the Monitor to get one the
314:              first time and holds onto it for later.
315:             */
316:            protected UUIDFactory getUUIDFactory() {
317:                if (uuidf == null)
318:                    uuidf = Monitor.getMonitor().getUUIDFactory();
319:                return uuidf;
320:            }
321:
322:            /**
323:              @see DataDescriptorGenerator#newFileInfoDescriptor
324:             */
325:            public FileInfoDescriptor newFileInfoDescriptor(UUID id,
326:                    SchemaDescriptor sd, String SQLName, long generationId) {
327:                if (id == null)
328:                    id = getUUIDFactory().createUUID();
329:                return new FileInfoDescriptor(dataDictionary, id, sd, SQLName,
330:                        generationId);
331:            }
332:
333:            public TablePermsDescriptor newTablePermsDescriptor(
334:                    TableDescriptor td, String selectPerm, String deletePerm,
335:                    String insertPerm, String updatePerm,
336:                    String referencesPerm, String triggerPerm, String grantor)
337:                    throws StandardException {
338:                if ("N".equals(selectPerm) && "N".equals(deletePerm)
339:                        && "N".equals(insertPerm) && "N".equals(updatePerm)
340:                        && "N".equals(referencesPerm)
341:                        && "N".equals(triggerPerm))
342:                    return null;
343:
344:                return new TablePermsDescriptor(dataDictionary, (String) null,
345:                        grantor, td.getUUID(), selectPerm, deletePerm,
346:                        insertPerm, updatePerm, referencesPerm, triggerPerm);
347:            }
348:
349:            /**
350:             * Manufacture a new ColPermsDescriptor.
351:             *
352:             * @param td The descriptor of the table.
353:             * @param type The action type:
354:             *<ol>
355:             *<li>"s" - select without grant
356:             *<li>"S" - select with grant
357:             *<li>"u" - update without grant
358:             *<li>"U" - update with grant
359:             *<li>"r" - references without grant
360:             *<li>"R" - references with grant
361:             *</ol>
362:             * @param columns the set of columns
363:             */
364:            public ColPermsDescriptor newColPermsDescriptor(TableDescriptor td,
365:                    String type, FormatableBitSet columns, String grantor)
366:                    throws StandardException {
367:                return new ColPermsDescriptor(dataDictionary, (String) null,
368:                        grantor, td.getUUID(), type, columns);
369:            }
370:
371:            /**
372:             * Create a new routine permissions descriptor
373:             *
374:             * @param ad The routine's alias descriptor
375:             * @param grantor
376:             */
377:            public RoutinePermsDescriptor newRoutinePermsDescriptor(
378:                    AliasDescriptor ad, String grantor)
379:                    throws StandardException {
380:                return new RoutinePermsDescriptor(dataDictionary,
381:                        (String) null, grantor, ad.getUUID());
382:            }
383:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.