1 | /* |
2 | |
3 | Derby - Class org.apache.derby.iapi.sql.dictionary.FileInfoDescriptor |
4 | |
5 | Copyright 1998, 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 | |
21 | package org.apache.derby.iapi.sql.dictionary; |
22 | |
23 | import org.apache.derby.iapi.error.StandardException; |
24 | import org.apache.derby.iapi.sql.depend.Provider; |
25 | import org.apache.derby.catalog.UUID; |
26 | |
27 | import org.apache.derby.iapi.reference.SQLState; |
28 | import org.apache.derby.iapi.services.sanity.SanityManager; |
29 | import org.apache.derby.iapi.sql.StatementType; |
30 | import org.apache.derby.catalog.DependableFinder; |
31 | import org.apache.derby.catalog.Dependable; |
32 | import org.apache.derby.iapi.services.io.StoredFormatIds; |
33 | |
34 | /** |
35 | * A Descriptor for a file that has been stored in the database. |
36 | */ |
37 | public class FileInfoDescriptor extends TupleDescriptor |
38 | implements Provider, UniqueSQLObjectDescriptor |
39 | { |
40 | /** A type tho indicate the file is a jar file **/ |
41 | public static final int JAR_FILE_TYPE = 0; |
42 | |
43 | /** external interface to this class: |
44 | <ol> |
45 | <li>public long getGenerationId(); |
46 | </ol> |
47 | */ |
48 | UUID id; |
49 | SchemaDescriptor sd; |
50 | String sqlName; |
51 | long generationId; |
52 | |
53 | /** |
54 | * Constructor for a FileInfoDescriptor. |
55 | * |
56 | * @param dataDictionary The data dictionary that this descriptor lives in |
57 | * @param id The id for this file |
58 | * @param sd The schema for this file. |
59 | * @param sqlName The SQL name of this file. |
60 | * @param generationId The generation id for the |
61 | * version of the file this describes. |
62 | */ |
63 | |
64 | public FileInfoDescriptor(DataDictionary dataDictionary, |
65 | UUID id, |
66 | SchemaDescriptor sd, |
67 | String sqlName, |
68 | long generationId) |
69 | { |
70 | super( dataDictionary ); |
71 | |
72 | if (SanityManager.DEBUG) |
73 | { |
74 | if (sd.getSchemaName() == null) |
75 | { |
76 | SanityManager.THROWASSERT("new FileInfoDescriptor() schema "+ |
77 | "name is null for FileInfo "+sqlName); |
78 | } |
79 | } |
80 | this.id = id; |
81 | this.sd = sd; |
82 | this.sqlName = sqlName; |
83 | this.generationId = generationId; |
84 | } |
85 | |
86 | public SchemaDescriptor getSchemaDescriptor() |
87 | { |
88 | return sd; |
89 | } |
90 | |
91 | public String getName() |
92 | { |
93 | return sqlName; |
94 | } |
95 | |
96 | /** |
97 | * @see UniqueTupleDescriptor#getUUID |
98 | */ |
99 | public UUID getUUID() |
100 | { |
101 | return id; |
102 | } |
103 | |
104 | /** |
105 | * Gets the generationId for the current version of this file. The |
106 | * triple (schemaName,SQLName,generationId) are unique for the |
107 | * life of this database. |
108 | * |
109 | * @return the generationId for this file |
110 | */ |
111 | public long getGenerationId() |
112 | { |
113 | return generationId; |
114 | } |
115 | |
116 | // |
117 | // Provider interface |
118 | // |
119 | |
120 | /** |
121 | @see Dependable#getDependableFinder |
122 | */ |
123 | public DependableFinder getDependableFinder() |
124 | { |
125 | return getDependableFinder(StoredFormatIds.FILE_INFO_FINDER_V01_ID); |
126 | } |
127 | |
128 | /** |
129 | @see Dependable#getObjectName |
130 | */ |
131 | public String getObjectName() |
132 | { |
133 | return sqlName; |
134 | } |
135 | |
136 | /** |
137 | @see Dependable#getObjectID |
138 | */ |
139 | public UUID getObjectID() |
140 | { |
141 | return id; |
142 | } |
143 | |
144 | /** |
145 | @see Dependable#getClassType |
146 | */ |
147 | public String getClassType() |
148 | { |
149 | return Dependable.FILE; |
150 | } |
151 | |
152 | // |
153 | // class interface |
154 | // |
155 | |
156 | |
157 | /** @see TupleDescriptor#getDescriptorType */ |
158 | public String getDescriptorType() { return "Jar file"; } |
159 | |
160 | /** @see TupleDescriptor#getDescriptorName */ |
161 | public String getDescriptorName() { return sqlName; } |
162 | |
163 | |
164 | |
165 | } |