KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > sql > CursorTableReference


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.CursorTableReference
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.sql;
23
24 import org.apache.derby.iapi.sql.execute.ExecCursorTableReference;
25 import org.apache.derby.iapi.services.sanity.SanityManager;
26
27 import org.apache.derby.iapi.services.io.StoredFormatIds;
28 import org.apache.derby.iapi.services.io.FormatIdUtil;
29 import org.apache.derby.iapi.services.io.Formatable;
30
31 import java.io.ObjectOutput JavaDoc;
32 import java.io.ObjectInput JavaDoc;
33 import java.io.IOException JavaDoc;
34 /**
35  *
36  * @author jamie
37  */

38 public class CursorTableReference
39     implements ExecCursorTableReference, Formatable
40 {
41
42     /********************************************************
43     **
44     ** This class implements Formatable. That means that it
45     ** can write itself to and from a formatted stream. If
46     ** you add more fields to this class, make sure that you
47     ** also write/read them with the writeExternal()/readExternal()
48     ** methods.
49     **
50     ** If, inbetween releases, you add more fields to this class,
51     ** then you should bump the version number emitted by the getTypeFormatId()
52     ** method.
53     **
54     ********************************************************/

55
56     private String JavaDoc exposedName;
57     private String JavaDoc baseName;
58     private String JavaDoc schemaName;
59
60     /**
61      * Niladic constructor for Formatable
62      */

63     public CursorTableReference()
64     {
65     }
66
67     /**
68      *
69      */

70     public CursorTableReference
71     (
72         String JavaDoc exposedName,
73         String JavaDoc baseName,
74         String JavaDoc schemaName
75     )
76     {
77         this.exposedName = exposedName;
78         this.baseName = baseName;
79         this.schemaName = schemaName;
80     }
81
82     /**
83      * Return the base name of the table
84      *
85      * @return the base name
86      */

87     public String JavaDoc getBaseName()
88     {
89         return baseName;
90     }
91
92     /**
93      * Return the exposed name of the table. Exposed
94      * name is another term for correlation name. If
95      * there is no correlation, this will return the base
96      * name.
97      *
98      * @return the base name
99      */

100     public String JavaDoc getExposedName()
101     {
102         return exposedName;
103     }
104
105     /**
106      * Return the schema for the table.
107      *
108      * @return the schema name
109      */

110     public String JavaDoc getSchemaName()
111     {
112         return schemaName;
113     }
114
115     //////////////////////////////////////////////
116
//
117
// FORMATABLE
118
//
119
//////////////////////////////////////////////
120
/**
121      * Write this object out
122      *
123      * @param out write bytes here
124      *
125      * @exception IOException thrown on error
126      */

127     public void writeExternal(ObjectOutput JavaDoc out) throws IOException JavaDoc
128     {
129         out.writeObject(baseName);
130         out.writeObject(exposedName);
131         out.writeObject(schemaName);
132     }
133
134     /**
135      * Read this object from a stream of stored objects.
136      *
137      * @param in read this.
138      *
139      * @exception IOException thrown on error
140      * @exception ClassNotFoundException thrown on error
141      */

142     public void readExternal(ObjectInput JavaDoc in)
143         throws IOException JavaDoc, ClassNotFoundException JavaDoc
144     {
145         baseName = (String JavaDoc)in.readObject();
146         exposedName = (String JavaDoc)in.readObject();
147         schemaName = (String JavaDoc)in.readObject();
148     }
149     
150     /**
151      * Get the formatID which corresponds to this class.
152      *
153      * @return the formatID of this class
154      */

155     public int getTypeFormatId() { return StoredFormatIds.CURSOR_TABLE_REFERENCE_V01_ID; }
156
157     public String JavaDoc toString()
158     {
159         if (SanityManager.DEBUG)
160         {
161             return "CursorTableReference"+
162                 "\n\texposedName: "+exposedName+
163                 "\n\tbaseName: "+baseName+
164                 "\n\tschemaName: "+schemaName;
165         }
166         else
167         {
168             return "";
169         }
170     }
171 }
172
Popular Tags