001: /*
002:
003: Derby - Class org.apache.derby.impl.sql.CursorTableReference
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.impl.sql;
023:
024: import org.apache.derby.iapi.sql.execute.ExecCursorTableReference;
025: import org.apache.derby.iapi.services.sanity.SanityManager;
026:
027: import org.apache.derby.iapi.services.io.StoredFormatIds;
028: import org.apache.derby.iapi.services.io.FormatIdUtil;
029: import org.apache.derby.iapi.services.io.Formatable;
030:
031: import java.io.ObjectOutput;
032: import java.io.ObjectInput;
033: import java.io.IOException;
034:
035: /**
036: *
037: * @author jamie
038: */
039: public class CursorTableReference implements ExecCursorTableReference,
040: Formatable {
041:
042: /********************************************************
043: **
044: ** This class implements Formatable. That means that it
045: ** can write itself to and from a formatted stream. If
046: ** you add more fields to this class, make sure that you
047: ** also write/read them with the writeExternal()/readExternal()
048: ** methods.
049: **
050: ** If, inbetween releases, you add more fields to this class,
051: ** then you should bump the version number emitted by the getTypeFormatId()
052: ** method.
053: **
054: ********************************************************/
055:
056: private String exposedName;
057: private String baseName;
058: private String schemaName;
059:
060: /**
061: * Niladic constructor for Formatable
062: */
063: public CursorTableReference() {
064: }
065:
066: /**
067: *
068: */
069: public CursorTableReference(String exposedName, String baseName,
070: String schemaName) {
071: this .exposedName = exposedName;
072: this .baseName = baseName;
073: this .schemaName = schemaName;
074: }
075:
076: /**
077: * Return the base name of the table
078: *
079: * @return the base name
080: */
081: public String getBaseName() {
082: return baseName;
083: }
084:
085: /**
086: * Return the exposed name of the table. Exposed
087: * name is another term for correlation name. If
088: * there is no correlation, this will return the base
089: * name.
090: *
091: * @return the base name
092: */
093: public String getExposedName() {
094: return exposedName;
095: }
096:
097: /**
098: * Return the schema for the table.
099: *
100: * @return the schema name
101: */
102: public String getSchemaName() {
103: return schemaName;
104: }
105:
106: //////////////////////////////////////////////
107: //
108: // FORMATABLE
109: //
110: //////////////////////////////////////////////
111: /**
112: * Write this object out
113: *
114: * @param out write bytes here
115: *
116: * @exception IOException thrown on error
117: */
118: public void writeExternal(ObjectOutput out) throws IOException {
119: out.writeObject(baseName);
120: out.writeObject(exposedName);
121: out.writeObject(schemaName);
122: }
123:
124: /**
125: * Read this object from a stream of stored objects.
126: *
127: * @param in read this.
128: *
129: * @exception IOException thrown on error
130: * @exception ClassNotFoundException thrown on error
131: */
132: public void readExternal(ObjectInput in) throws IOException,
133: ClassNotFoundException {
134: baseName = (String) in.readObject();
135: exposedName = (String) in.readObject();
136: schemaName = (String) in.readObject();
137: }
138:
139: /**
140: * Get the formatID which corresponds to this class.
141: *
142: * @return the formatID of this class
143: */
144: public int getTypeFormatId() {
145: return StoredFormatIds.CURSOR_TABLE_REFERENCE_V01_ID;
146: }
147:
148: public String toString() {
149: if (SanityManager.DEBUG) {
150: return "CursorTableReference" + "\n\texposedName: "
151: + exposedName + "\n\tbaseName: " + baseName
152: + "\n\tschemaName: " + schemaName;
153: } else {
154: return "";
155: }
156: }
157: }
|