EMMA Coverage Report (generated Wed Jun 28 22:15:27 PDT 2006)
[all classes][org.apache.derby.iapi.sql.dictionary]

COVERAGE SUMMARY FOR SOURCE FILE [DataDescriptorGenerator.java]

nameclass, %method, %block, %line, %
DataDescriptorGenerator.java100% (1/1)93%  (14/15)91%  (199/219)90%  (19/21)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DataDescriptorGenerator100% (1/1)93%  (14/15)91%  (199/219)90%  (19/21)
DataDescriptorGenerator (DataDictionary): void 100% (1/1)100% (6/6)100% (3/3)
getUUIDFactory (): UUIDFactory 100% (1/1)100% (10/10)100% (3/3)
newCheckConstraintDescriptor (TableDescriptor, String, boolean, boolean, UUID... 100% (1/1)100% (15/15)100% (1/1)
newCheckConstraintDescriptor (TableDescriptor, String, boolean, boolean, UUID... 0%   (0/1)0%   (0/20)0%   (0/2)
newConglomerateDescriptor (long, String, boolean, IndexRowGenerator, boolean,... 100% (1/1)100% (14/14)100% (1/1)
newFileInfoDescriptor (UUID, SchemaDescriptor, String, long): FileInfoDescriptor 100% (1/1)100% (16/16)100% (2/2)
newForeignKeyConstraintDescriptor (TableDescriptor, String, boolean, boolean,... 100% (1/1)100% (18/18)100% (1/1)
newForeignKeyConstraintDescriptor (TableDescriptor, String, boolean, boolean,... 100% (1/1)100% (18/18)100% (1/1)
newPrimaryKeyConstraintDescriptor (TableDescriptor, String, boolean, boolean,... 100% (1/1)100% (17/17)100% (1/1)
newSchemaDescriptor (String, String, UUID): SchemaDescriptor 100% (1/1)100% (13/13)100% (1/1)
newTableDescriptor (String, SchemaDescriptor, int, boolean, boolean): TableDe... 100% (1/1)100% (11/11)100% (1/1)
newTableDescriptor (String, SchemaDescriptor, int, char): TableDescriptor 100% (1/1)100% (10/10)100% (1/1)
newTriggerDescriptor (SchemaDescriptor, UUID, String, int, boolean, boolean, ... 100% (1/1)100% (23/23)100% (1/1)
newUniqueConstraintDescriptor (TableDescriptor, String, boolean, boolean, int... 100% (1/1)100% (17/17)100% (1/1)
newViewDescriptor (UUID, String, String, int, UUID): ViewDescriptor 100% (1/1)100% (11/11)100% (1/1)

1/*
2 
3   Derby - Class org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator
4 
5   Copyright 1997, 2004 The Apache Software Foundation or its licensors, as applicable.
6 
7   Licensed under the Apache License, Version 2.0 (the "License");
8   you may not use this file except in compliance with the License.
9   You may obtain a copy of the License at
10 
11      http://www.apache.org/licenses/LICENSE-2.0
12 
13   Unless required by applicable law or agreed to in writing, software
14   distributed under the License is distributed on an "AS IS" BASIS,
15   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   See the License for the specific language governing permissions and
17   limitations under the License.
18 
19 */
20 
21package org.apache.derby.iapi.sql.dictionary;
22 
23import org.apache.derby.iapi.services.monitor.Monitor;
24import org.apache.derby.iapi.error.StandardException;
25 
26import org.apache.derby.iapi.sql.dictionary.*;
27 
28import org.apache.derby.iapi.types.TypeId;
29import org.apache.derby.iapi.sql.depend.Dependent;
30import org.apache.derby.iapi.sql.depend.Provider;
31import org.apache.derby.iapi.reference.SQLState;
32import org.apache.derby.iapi.sql.execute.ConstantAction;
33import org.apache.derby.iapi.sql.execute.ExecPreparedStatement;
34import org.apache.derby.iapi.services.uuid.UUIDFactory;
35import org.apache.derby.iapi.services.io.FormatableBitSet;
36 
37import org.apache.derby.catalog.AliasInfo;
38import org.apache.derby.catalog.DefaultInfo;
39import org.apache.derby.catalog.Dependable;
40import org.apache.derby.catalog.DependableFinder;
41import org.apache.derby.catalog.ReferencedColumns;
42import org.apache.derby.catalog.types.ReferencedColumnsDescriptorImpl;
43import org.apache.derby.catalog.UUID;
44import org.apache.derby.catalog.Statistics;
45import java.sql.Timestamp;
46import java.io.InputStream;
47 
48/**
49 * This is an implementation of the DataDescriptorGenerator interface
50 * that lives in the DataDictionary protocol.  See that interface for
51 * a description of what this class is supposed to do.
52 *
53 * @version 0.1
54 * @author Jeff Lichtman
55 */
56 
57public class DataDescriptorGenerator 
58{
59        private         UUIDFactory uuidf;
60 
61    protected        final DataDictionary        dataDictionary; // the data dictionary that this generator operates on
62 
63        /**
64          *        Make a generator. Specify the data dictionary that it operates on.
65          *
66          *        @param        dataDictionary        the data dictionary that this generator makes objects for
67          */
68        public        DataDescriptorGenerator( DataDictionary dataDictionary )
69        {
70                this.dataDictionary = dataDictionary;
71        }
72 
73        /**
74         * Create a descriptor for the named schema with a null UUID. 
75         *
76         * @param schemaName        The name of the schema we're interested in.
77         *                        If the name is NULL, get the descriptor for the
78         *                        current schema.
79         * @param aid        The authorization ID associated with the schema.
80         *                The owner of the schema.
81         *
82         * @param oid        The object ID 
83         *
84         * @return        The descriptor for the schema.
85         * @exception StandardException                Thrown on failure
86         */
87        public SchemaDescriptor        newSchemaDescriptor(String schemaName, 
88                String aid, UUID oid)
89                throws StandardException
90        {
91                return new SchemaDescriptor(
92            dataDictionary, schemaName, aid, oid, 
93            dataDictionary.isSystemSchemaName(schemaName));
94        }
95 
96        /**
97         * Create a descriptor for the named table within the given schema.
98         * If the schema parameter is NULL, it creates a schema descriptor
99         * using the current default schema.
100         *
101         * @param tableName        The name of the table to get the descriptor for
102         * @param schema        The descriptor for the schema the table lives in.
103         *                        If null, use the current (default) schema.
104         * @param tableType        The type of the table: base table or view.
105         * @param lockGranularity        The lock granularity.
106         *
107         * @return        The descriptor for the table.
108         */
109        public TableDescriptor        newTableDescriptor
110        (
111                String                                 tableName,
112                SchemaDescriptor        schema,
113                int                                        tableType,
114                char                                lockGranularity
115    )
116        {
117                return new TableDescriptor
118                        (dataDictionary, tableName, schema, tableType, lockGranularity);
119        }
120 
121        /**
122         * Create a descriptor for the temporary table within the given schema.
123         *
124         * @param tableName        The name of the temporary table to get the descriptor for
125         * @param schema        The descriptor for the schema the table lives in.
126         * @param tableType        The type of the table: temporary table
127         * @param onCommitDeleteRows        If true, on commit delete rows else on commit preserve rows of temporary table.
128         * @param onRollbackDeleteRows        If true, on rollback, delete rows from temp tables which were logically modified. true is the only supported value
129         *
130         * @return        The descriptor for the table.
131         */
132        public TableDescriptor        newTableDescriptor
133        (
134                String                                 tableName,
135                SchemaDescriptor        schema,
136                int                                        tableType,
137                boolean                                onCommitDeleteRows,
138                boolean                                onRollbackDeleteRows
139    )
140        {
141                return new TableDescriptor
142                        (dataDictionary, tableName, schema, tableType, onCommitDeleteRows, onRollbackDeleteRows);
143        }
144 
145        /**
146         * Create a viewDescriptor for the view with the given UUID.
147         *
148         * @param viewID        the UUID for the view.
149         * @param viewName        the name of the view
150         * @param viewText        the text of the view's query.
151         * @param checkOption        int for check option type 
152         * @param compSchemaId        the UUID of the schema this was compiled in
153         *
154         * @return        A descriptor for the view
155         */
156        public ViewDescriptor newViewDescriptor(UUID viewID,
157                                String viewName, String viewText, int checkOption,
158                                UUID compSchemaId)
159        {
160                return new ViewDescriptor(dataDictionary, viewID, viewName, 
161                                viewText, checkOption, compSchemaId);
162        }
163 
164 
165        /**
166         * @see DataDescriptorGenerator#newUniqueConstraintDescriptor
167         */
168        public ReferencedKeyConstraintDescriptor        newUniqueConstraintDescriptor(
169                                                TableDescriptor table,
170                                                String constraintName,
171                                                boolean deferrable,
172                                                boolean initiallyDeferred,
173                                                int[] referencedColumns,
174                                                UUID                constraintId,
175                                                UUID                indexId,
176                                                SchemaDescriptor schemaDesc,
177                                                boolean isEnabled,
178                                                int referenceCount
179                                                )
180        {
181                return new ReferencedKeyConstraintDescriptor(DataDictionary.UNIQUE_CONSTRAINT,
182                        dataDictionary, table, constraintName,
183                                deferrable, initiallyDeferred, 
184                                referencedColumns, constraintId, 
185                                indexId, schemaDesc, isEnabled, referenceCount);
186        }
187 
188        /**
189         * @see DataDescriptorGenerator#newPrimaryKeyConstraintDescriptor
190         */
191        public ReferencedKeyConstraintDescriptor        newPrimaryKeyConstraintDescriptor(
192                                                TableDescriptor table,
193                                                String constraintName,
194                                                boolean deferrable,
195                                                boolean initiallyDeferred,
196                                                int[] referencedColumns,
197                                                UUID                constraintId,
198                                                UUID indexId,
199                                                SchemaDescriptor schemaDesc,
200                                                boolean isEnabled,
201                                                int referenceCount
202                                                )
203        {
204                return new ReferencedKeyConstraintDescriptor(DataDictionary.PRIMARYKEY_CONSTRAINT,
205                        dataDictionary, table, constraintName,
206                                deferrable, initiallyDeferred, 
207                                referencedColumns, constraintId, 
208                                indexId, schemaDesc, isEnabled, referenceCount);
209        }
210 
211        /**
212         * @see DataDescriptorGenerator#newForeignKeyConstraintDescriptor
213         */
214        public ForeignKeyConstraintDescriptor        newForeignKeyConstraintDescriptor(
215                                                TableDescriptor table,
216                                                String constraintName,
217                                                boolean deferrable,
218                                                boolean initiallyDeferred,
219                                                int[] fkColumns,
220                                                UUID        constraintId,
221                                                UUID indexId,
222                                                SchemaDescriptor schemaDesc,
223                                                ReferencedKeyConstraintDescriptor        referencedConstraintDescriptor,
224                                                boolean isEnabled,
225                                                int raDeleteRule,
226                                                int raUpdateRule
227                                                )
228        {
229                return new ForeignKeyConstraintDescriptor(dataDictionary, table, constraintName,
230                                deferrable, initiallyDeferred, 
231                                fkColumns, constraintId, 
232                                indexId, schemaDesc, 
233                                referencedConstraintDescriptor, isEnabled, raDeleteRule, raUpdateRule);
234        }
235 
236 
237        /**
238         * @see DataDescriptorGenerator#newForeignKeyConstraintDescriptor
239         */
240        public ForeignKeyConstraintDescriptor        newForeignKeyConstraintDescriptor(
241                                                TableDescriptor table,
242                                                String constraintName,
243                                                boolean deferrable,
244                                                boolean initiallyDeferred,
245                                                int[] fkColumns,
246                                                UUID        constraintId,
247                                                UUID indexId,
248                                                SchemaDescriptor schemaDesc,
249                                                UUID        referencedConstraintId,
250                                                boolean isEnabled,
251                                                int raDeleteRule,
252                                                int raUpdateRule
253                                                )
254        {
255                return new ForeignKeyConstraintDescriptor(dataDictionary, table, constraintName,
256                                deferrable, initiallyDeferred, 
257                                fkColumns, constraintId, 
258                                indexId, schemaDesc, 
259                                referencedConstraintId, isEnabled, raDeleteRule, raUpdateRule);
260        }
261 
262        /**
263         * @see DataDescriptorGenerator#newCheckConstraintDescriptor
264         */
265        public CheckConstraintDescriptor        newCheckConstraintDescriptor(
266                                                TableDescriptor table,
267                                                String constraintName,
268                                                boolean deferrable,
269                                                boolean initiallyDeferred,
270                                                UUID                constraintId,
271                                                String constraintText,
272                                                ReferencedColumns referencedColumns,
273                                                SchemaDescriptor schemaDesc,
274                                                boolean isEnabled
275                                                )
276        {
277                return new CheckConstraintDescriptor(dataDictionary, table, constraintName,
278                                deferrable, initiallyDeferred, 
279                                constraintId, 
280                                constraintText, referencedColumns, schemaDesc, isEnabled);
281        }
282 
283        public CheckConstraintDescriptor        newCheckConstraintDescriptor(
284                                                TableDescriptor table,
285                                                String constraintName,
286                                                boolean deferrable,
287                                                boolean initiallyDeferred,
288                                                UUID                constraintId,
289                                                String constraintText,
290                                                int[] refCols,
291                                                SchemaDescriptor schemaDesc,
292                                                boolean isEnabled
293                                                )
294        {
295                ReferencedColumns referencedColumns = new ReferencedColumnsDescriptorImpl(refCols);
296                return new CheckConstraintDescriptor(dataDictionary, table, constraintName,
297                                deferrable, initiallyDeferred, 
298                                constraintId, 
299                                constraintText, referencedColumns, schemaDesc, isEnabled);
300        }
301 
302        /**
303         * Create a conglomerate descriptor for the given conglomerate id.
304         *
305         * @param conglomerateId        The identifier for the conglomerate
306         *                                we're interested in
307         * @param name                        The name of the conglomerate, if any
308         * @param indexable                TRUE means the conglomerate is indexable,
309         *                                FALSE means it isn't
310         * @param indexRowGenerator        The IndexRowGenerator for the conglomerate,
311         *                                                        null if it's a heap
312         * @param isConstraint        TRUE means the conglomerate is an index backing 
313         *                                                up a constraint, FALSE means it isn't
314         *
315         * @param uuid        UUID  for this conglomerate
316         * @param tableID        UUID for the table that this conglomerate belongs to
317         * @param schemaID        UUID for the schema that conglomerate belongs to
318         *
319         * @return        A ConglomerateDescriptor describing the 
320         *                conglomerate. 
321         */
322        public ConglomerateDescriptor        newConglomerateDescriptor(
323                                                long conglomerateId,
324                                                String name,
325                                                boolean indexable,
326                                                IndexRowGenerator indexRowGenerator,
327                                                boolean isConstraint,
328                                                UUID uuid,
329                                                UUID tableID,
330                                                UUID schemaID
331                                                )
332        {
333                return (ConglomerateDescriptor)
334                                new ConglomerateDescriptor(dataDictionary, conglomerateId,
335                                                                                                name,
336                                                                                                indexable,
337                                                                                                indexRowGenerator,
338                                                                                                isConstraint,
339                                                                                                uuid,
340                                                                                            tableID,
341                                                                                                schemaID);
342        }
343 
344        /**
345         * Create a new trigger descriptor.
346         *
347         * @param sd        the schema descriptor for this trigger
348         * @param uuid        the trigger id
349         * @param name        the trigger name
350         * @param eventMask        TriggerDescriptor.TRIGGER_EVENT_XXXX
351         * @param isBefore        is this a before (as opposed to after) trigger 
352         * @param isRow                is this a row trigger or statement trigger
353         * @param isEnabled        is this trigger enabled or disabled
354         * @param td                the table upon which this trigger is defined
355         * @param whenSPSId        the sps id for the when clause (may be null)
356         * @param actionSPSId        the spsid for the trigger action (may be null)
357         * @param creationTimestamp        when was this trigger created?
358         * @param referencedCols        what columns does this trigger reference (may be null)
359         * @param triggerDefinition The original user text of the trigger action
360         * @param referencingOld whether or not OLD appears in REFERENCING clause
361         * @param referencingNew whether or not NEW appears in REFERENCING clause
362         * @param oldReferencingName old referencing table name, if any, that appears in REFERCING clause
363         * @param newReferencingName new referencing table name, if any, that appears in REFERCING clause
364         *
365         * @exception StandardException on error
366         */
367        public TriggerDescriptor newTriggerDescriptor
368        (
369                SchemaDescriptor        sd,
370                UUID                                uuid,
371                String                                name,
372                int                                        eventMask,
373                boolean                                isBefore,
374                boolean                         isRow,
375                boolean                         isEnabled,
376                TableDescriptor                td,
377                UUID                                whenSPSId,
378                UUID                                actionSPSId,
379                Timestamp                        creationTimestamp,
380                int[]                                referencedCols,
381                String                                triggerDefinition,
382                boolean                                referencingOld,
383                boolean                                referencingNew,
384                String                                oldReferencingName,
385                String                                newReferencingName
386        ) throws StandardException
387        {
388                return new TriggerDescriptor(
389                                        dataDictionary,
390                                        sd,
391                                        uuid,
392                                        name,
393                                        eventMask,
394                                        isBefore,
395                                        isRow,
396                                        isEnabled,
397                                        td,
398                                        whenSPSId,
399                                        actionSPSId,
400                                        creationTimestamp,
401                                        referencedCols,
402                                        triggerDefinition,
403                                        referencingOld,
404                                        referencingNew,
405                                        oldReferencingName,
406                                        newReferencingName
407                                        );
408        }
409                
410        /*
411          get a UUIDFactory. This uses the Monitor to get one the
412          first time and holds onto it for later.
413          */
414        protected UUIDFactory getUUIDFactory()
415        {
416                if (uuidf == null)
417                        uuidf = Monitor.getMonitor().getUUIDFactory();
418                return uuidf;
419        }
420 
421        /**
422          @see DataDescriptorGenerator#newFileInfoDescriptor
423          */
424        public FileInfoDescriptor newFileInfoDescriptor(
425                                                                UUID             id,
426                                                                SchemaDescriptor sd,
427                                                                String           SQLName,
428                                                                long              generationId
429                                                                )
430        {
431                if (id == null) id = getUUIDFactory().createUUID();
432                return new FileInfoDescriptor(dataDictionary, id,sd,SQLName,generationId);
433        }
434                 
435    public TablePermsDescriptor newTablePermsDescriptor( TableDescriptor td,
436                                                         String selectPerm,
437                                                         String deletePerm,
438                                                         String insertPerm,
439                                                         String updatePerm,
440                                                         String referencesPerm,
441                                                         String triggerPerm,
442                                                         String grantor)
443    {
444        if( "N".equals( selectPerm) && "N".equals( deletePerm) && "N".equals( insertPerm)
445            && "N".equals( updatePerm) && "N".equals( referencesPerm) && "N".equals( triggerPerm))
446            return null;
447        
448        return new TablePermsDescriptor( dataDictionary,
449                                         (String) null,
450                                         grantor,
451                                         td.getUUID(),
452                                         selectPerm,
453                                         deletePerm,
454                                         insertPerm,
455                                         updatePerm,
456                                         referencesPerm,
457                                         triggerPerm);
458    }
459 
460    /**
461     * Manufacture a new ColPermsDescriptor.
462     *
463     * @param td The descriptor of the table.
464     * @param type The action type:
465     *<ol>
466     *<li>"s" - select without grant
467     *<li>"S" - select with grant
468     *<li>"u" - update without grant
469     *<li>"U" - update with grant
470     *<li>"r" - references without grant
471     *<li>"R" - references with grant
472     *</ol>
473     * @param columns the set of columns
474     */
475    public ColPermsDescriptor newColPermsDescriptor( TableDescriptor td,
476                                                     String type,
477                                                     FormatableBitSet columns,
478                                                     String grantor)
479    {
480        return new ColPermsDescriptor( dataDictionary,
481                                       (String) null,
482                                       grantor,
483                                       td.getUUID(),
484                                       type,
485                                       columns);
486    }
487 
488    /**
489     * Create a new routine permissions descriptor
490     *
491     * @param ad The routine's alias descriptor
492     * @param grantor
493     */
494    public RoutinePermsDescriptor newRoutinePermsDescriptor( AliasDescriptor ad, String grantor)
495    {
496        return new RoutinePermsDescriptor( dataDictionary,
497                                           (String) null,
498                                           grantor,
499                                           ad.getUUID());
500    }
501}

[all classes][org.apache.derby.iapi.sql.dictionary]
EMMA 2.0.5312 (C) Vladimir Roubtsov