00001
package com.quadcap.sql;
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
import java.io.Externalizable;
00042
import java.io.IOException;
00043
import java.io.ObjectInput;
00044
import java.io.ObjectOutput;
00045
00046
import java.util.Vector;
00047
00048
import java.sql.SQLException;
00049
00050
import com.quadcap.util.Debug;
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 public class SelectFromItem extends TableExpression implements
Externalizable {
00065 TableExpression e;
00066 String
asName = null;
00067 Vector
columns = null;
00068
00069 public SelectFromItem() {}
00070
00071 public SelectFromItem(
TableExpression e, String asName, Vector columns) {
00072
this.e = e;
00073
this.asName = asName;
00074
this.columns = columns;
00075 }
00076
00077 public void readExternal(ObjectInput in)
00078
throws IOException, ClassNotFoundException
00079 {
00080
this.e = (
TableExpression)in.readObject();
00081
this.asName = (String)in.readObject();
00082
this.columns = (Vector)in.readObject();
00083 }
00084
00085 public void writeExternal(ObjectOutput out)
throws IOException {
00086 out.writeObject(
e);
00087 out.writeObject(
asName);
00088 out.writeObject(
columns);
00089 }
00090
00091 public int rank() {
return e.
rank(); }
00092
00093 public boolean isUpdatable() {
return e.
isUpdatable(); }
00094
00095 public void getBaseTables(Vector v) {
00096
e.
getBaseTables(v);
00097 }
00098
00099 public void setWhere(
Expression where) {
00100
this.where = where;
00101
e.
setWhere(where);
00102 }
00103
00104 public Cursor getCursor(
Session session,
Cursor outer)
00105
throws SQLException
00106 {
00107
Cursor c =
e.
getCursor(session, outer);
00108
return new RenameCursor(session, c,
asName,
columns);
00109 }
00110
00111 public String
toString() {
00112 StringBuffer sb =
new StringBuffer(
e.
toString());
00113
if (
asName != null &&
asName.length() > 0) {
00114 sb.append(
" AS ");
00115 sb.append(
asName);
00116
if (
columns != null) {
00117 sb.append(
'(');
00118
for (
int i = 0; i <
columns.size(); i++) {
00119
if (i > 0) sb.append(
',');
00120 sb.append(
columns.get(i));
00121 }
00122 sb.append(
')');
00123 }
00124 }
00125
return sb.toString();
00126 }
00127
00128
00129 public String
name() {
00130 StringBuffer sb =
new StringBuffer(
e.
name());
00131
if (
asName != null) {
00132 sb.append(
" AS ");
00133 sb.append(
asName);
00134 }
00135
return sb.toString();
00136 }
00137
00138 }
00139