001: /*
002:
003: Derby - Class org.apache.derby.iapi.sql.dictionary.FileInfoDescriptor
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.error.StandardException;
025: import org.apache.derby.iapi.sql.depend.Provider;
026: import org.apache.derby.catalog.UUID;
027:
028: import org.apache.derby.iapi.reference.SQLState;
029: import org.apache.derby.iapi.services.sanity.SanityManager;
030: import org.apache.derby.iapi.sql.StatementType;
031: import org.apache.derby.catalog.DependableFinder;
032: import org.apache.derby.catalog.Dependable;
033: import org.apache.derby.iapi.services.io.StoredFormatIds;
034:
035: /**
036: * A Descriptor for a file that has been stored in the database.
037: */
038: public final class FileInfoDescriptor extends TupleDescriptor implements
039: Provider, UniqueSQLObjectDescriptor {
040: /** A type tho indicate the file is a jar file **/
041: public static final int JAR_FILE_TYPE = 0;
042:
043: /** external interface to this class:
044: <ol>
045: <li>public long getGenerationId();
046: </ol>
047: */
048: private final UUID id;
049: private final SchemaDescriptor sd;
050: private final String sqlName;
051: private final long generationId;
052:
053: /**
054: * Constructor for a FileInfoDescriptor.
055: *
056: * @param dataDictionary The data dictionary that this descriptor lives in
057: * @param id The id for this file
058: * @param sd The schema for this file.
059: * @param sqlName The SQL name of this file.
060: * @param generationId The generation id for the
061: * version of the file this describes.
062: */
063:
064: public FileInfoDescriptor(DataDictionary dataDictionary, UUID id,
065: SchemaDescriptor sd, String sqlName, long generationId) {
066: super (dataDictionary);
067:
068: if (SanityManager.DEBUG) {
069: if (sd.getSchemaName() == null) {
070: SanityManager
071: .THROWASSERT("new FileInfoDescriptor() schema "
072: + "name is null for FileInfo "
073: + sqlName);
074: }
075: }
076: this .id = id;
077: this .sd = sd;
078: this .sqlName = sqlName;
079: this .generationId = generationId;
080: }
081:
082: public SchemaDescriptor getSchemaDescriptor() {
083: return sd;
084: }
085:
086: public String getName() {
087: return sqlName;
088: }
089:
090: /**
091: * @see UniqueTupleDescriptor#getUUID
092: */
093: public UUID getUUID() {
094: return id;
095: }
096:
097: /**
098: * Gets the generationId for the current version of this file. The
099: * triple (schemaName,SQLName,generationId) are unique for the
100: * life of this database.
101: *
102: * @return the generationId for this file
103: */
104: public long getGenerationId() {
105: return generationId;
106: }
107:
108: //
109: // Provider interface
110: //
111:
112: /**
113: @see Dependable#getDependableFinder
114: */
115: public DependableFinder getDependableFinder() {
116: return getDependableFinder(StoredFormatIds.FILE_INFO_FINDER_V01_ID);
117: }
118:
119: /**
120: @see Dependable#getObjectName
121: */
122: public String getObjectName() {
123: return sqlName;
124: }
125:
126: /**
127: @see Dependable#getObjectID
128: */
129: public UUID getObjectID() {
130: return id;
131: }
132:
133: /**
134: @see Dependable#getClassType
135: */
136: public String getClassType() {
137: return Dependable.FILE;
138: }
139:
140: //
141: // class interface
142: //
143:
144: /** @see TupleDescriptor#getDescriptorType */
145: public String getDescriptorType() {
146: return "Jar file";
147: }
148:
149: /** @see TupleDescriptor#getDescriptorName */
150: public String getDescriptorName() {
151: return sqlName;
152: }
153:
154: }
|