1 34 package smallsql.database; 35 36 import java.sql.SQLException ; 37 38 39 42 abstract class TableViewResult extends DataSource { 43 SSConnection con; 44 45 private String alias; 46 private long tableTimestamp; 47 int lock = SQLTokenizer.SELECT; 48 49 static TableViewResult createResult(TableView tableView){ 50 if(tableView instanceof Table) 51 return new TableResult((Table)tableView); 52 return new ViewResult( (View)tableView ); 53 } 54 55 56 static TableViewResult getTableViewResult(RowSource from) throws SQLException { 57 if(from instanceof Where){ 58 from = ((Where)from).getFrom(); 59 } 60 if(from instanceof TableViewResult){ 61 return (TableViewResult)from; 62 } 63 throw Utils.createSQLException("Rowsource is read only."); 64 } 65 66 void setAlias( String alias ){ 67 this.alias = alias; 68 } 69 70 71 String getAlias(){ 72 return (alias != null) ? alias : getTableView().name; 73 } 74 75 76 boolean hasAlias(){ 77 return alias != null; 78 } 79 80 81 88 boolean init( SSConnection con ) throws Exception { 89 TableView tableView = getTableView(); 90 if(tableTimestamp != tableView.getTimestamp()){ 91 this.con = con; 92 tableTimestamp = tableView.getTimestamp(); 93 return true; 94 } 95 return false; 96 } 97 98 99 101 abstract void deleteRow() throws SQLException ; 102 103 abstract void updateRow(Expression[] updateValues) throws Exception ; 104 105 abstract void insertRow(Expression[] updateValues) throws Exception ; 106 107 108 final boolean isScrollable(){ 109 return false; 110 } 111 112 } 113 | Popular Tags |