1 | /* |
2 | |
3 | Derby - Class org.apache.derby.impl.sql.CursorTableReference |
4 | |
5 | Copyright 1999, 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.impl.sql; |
22 | |
23 | import org.apache.derby.iapi.sql.execute.ExecCursorTableReference; |
24 | import org.apache.derby.iapi.services.sanity.SanityManager; |
25 | |
26 | import org.apache.derby.iapi.services.io.StoredFormatIds; |
27 | import org.apache.derby.iapi.services.io.FormatIdUtil; |
28 | import org.apache.derby.iapi.services.io.Formatable; |
29 | |
30 | import java.io.ObjectOutput; |
31 | import java.io.ObjectInput; |
32 | import java.io.IOException; |
33 | /** |
34 | * |
35 | * @author jamie |
36 | */ |
37 | public class CursorTableReference |
38 | implements ExecCursorTableReference, Formatable |
39 | { |
40 | |
41 | /******************************************************** |
42 | ** |
43 | ** This class implements Formatable. That means that it |
44 | ** can write itself to and from a formatted stream. If |
45 | ** you add more fields to this class, make sure that you |
46 | ** also write/read them with the writeExternal()/readExternal() |
47 | ** methods. |
48 | ** |
49 | ** If, inbetween releases, you add more fields to this class, |
50 | ** then you should bump the version number emitted by the getTypeFormatId() |
51 | ** method. |
52 | ** |
53 | ********************************************************/ |
54 | |
55 | private String exposedName; |
56 | private String baseName; |
57 | private String schemaName; |
58 | |
59 | /** |
60 | * Niladic constructor for Formatable |
61 | */ |
62 | public CursorTableReference() |
63 | { |
64 | } |
65 | |
66 | /** |
67 | * |
68 | */ |
69 | public CursorTableReference |
70 | ( |
71 | String exposedName, |
72 | String baseName, |
73 | String schemaName |
74 | ) |
75 | { |
76 | this.exposedName = exposedName; |
77 | this.baseName = baseName; |
78 | this.schemaName = schemaName; |
79 | } |
80 | |
81 | /** |
82 | * Return the base name of the table |
83 | * |
84 | * @return the base name |
85 | */ |
86 | public String getBaseName() |
87 | { |
88 | return baseName; |
89 | } |
90 | |
91 | /** |
92 | * Return the exposed name of the table. Exposed |
93 | * name is another term for correlation name. If |
94 | * there is no correlation, this will return the base |
95 | * name. |
96 | * |
97 | * @return the base name |
98 | */ |
99 | public String getExposedName() |
100 | { |
101 | return exposedName; |
102 | } |
103 | |
104 | /** |
105 | * Return the schema for the table. |
106 | * |
107 | * @return the schema name |
108 | */ |
109 | public String getSchemaName() |
110 | { |
111 | return schemaName; |
112 | } |
113 | |
114 | ////////////////////////////////////////////// |
115 | // |
116 | // FORMATABLE |
117 | // |
118 | ////////////////////////////////////////////// |
119 | /** |
120 | * Write this object out |
121 | * |
122 | * @param out write bytes here |
123 | * |
124 | * @exception IOException thrown on error |
125 | */ |
126 | public void writeExternal(ObjectOutput out) throws IOException |
127 | { |
128 | out.writeObject(baseName); |
129 | out.writeObject(exposedName); |
130 | out.writeObject(schemaName); |
131 | } |
132 | |
133 | /** |
134 | * Read this object from a stream of stored objects. |
135 | * |
136 | * @param in read this. |
137 | * |
138 | * @exception IOException thrown on error |
139 | * @exception ClassNotFoundException thrown on error |
140 | */ |
141 | public void readExternal(ObjectInput in) |
142 | throws IOException, ClassNotFoundException |
143 | { |
144 | baseName = (String)in.readObject(); |
145 | exposedName = (String)in.readObject(); |
146 | schemaName = (String)in.readObject(); |
147 | } |
148 | |
149 | /** |
150 | * Get the formatID which corresponds to this class. |
151 | * |
152 | * @return the formatID of this class |
153 | */ |
154 | public int getTypeFormatId() { return StoredFormatIds.CURSOR_TABLE_REFERENCE_V01_ID; } |
155 | |
156 | public String toString() |
157 | { |
158 | if (SanityManager.DEBUG) |
159 | { |
160 | return "CursorTableReference"+ |
161 | "\n\texposedName: "+exposedName+ |
162 | "\n\tbaseName: "+baseName+ |
163 | "\n\tschemaName: "+schemaName; |
164 | } |
165 | else |
166 | { |
167 | return ""; |
168 | } |
169 | } |
170 | } |