1 28 29 package com.caucho.db.sql; 30 31 import com.caucho.db.table.Column; 32 import com.caucho.db.table.Table; 33 import com.caucho.log.Log; 34 import com.caucho.util.L10N; 35 36 import java.sql.SQLException ; 37 import java.util.ArrayList ; 38 import java.util.logging.Logger ; 39 40 class UnboundStarExpr extends Expr { 41 private static final L10N L = new L10N(UnboundStarExpr.class); 42 private static final Logger log = Log.open(UnboundStarExpr.class); 43 44 private final String _table; 45 46 49 UnboundStarExpr() 50 { 51 _table = null; 52 } 53 54 57 UnboundStarExpr(String tableName) 58 { 59 _table = tableName; 60 } 61 62 protected Expr bind(Query query) 63 throws SQLException 64 { 65 return bind(query.getFromItems()); 66 } 67 68 protected Expr bind(FromItem []fromItems) 69 throws SQLException 70 { 71 return this; 72 } 73 74 protected ArrayList <Expr> expand(FromItem []fromItems) 75 throws SQLException 76 { 77 ArrayList <Expr> exprs = new ArrayList <Expr>(); 78 79 for (int i = 0; i < fromItems.length; i++) { 80 Table table = fromItems[i].getTable(); 81 Column []columns = table.getColumns(); 82 83 if (_table != null && ! fromItems[i].getName().equals(_table)) 84 continue; 85 86 for (int j = 0; j < columns.length; j++) { 87 exprs.add(new UnboundIdentifierExpr(fromItems[i].getName(), 88 columns[j].getName())); 89 } 90 } 91 92 return exprs; 93 } 94 95 public String toString() 96 { 97 return "UnboundStarExpr[]"; 98 } 99 } 100 | Popular Tags |