1 10 11 package com.triactive.jdo.store; 12 13 import javax.jdo.JDOFatalInternalException; 14 import javax.jdo.JDOUserException; 15 16 17 33 34 abstract class TableExpression 35 { 36 protected final QueryStatement qs; 37 protected final Table mainTable; 38 protected final SQLIdentifier mainRangeVar; 39 protected final StoreManager storeMgr; 40 protected String sqlText = null; 41 42 protected TableExpression(QueryStatement qs, Table mainTable, SQLIdentifier mainRangeVar) 43 { 44 this.qs = qs; 45 this.mainTable = mainTable; 46 this.mainRangeVar = mainRangeVar; 47 48 storeMgr = mainTable.getStoreManager(); 49 } 50 51 protected void assertNotFrozen() 52 { 53 if (sqlText != null) 54 throw new JDOFatalInternalException("A table expression cannot be modified after being output"); 55 } 56 57 public final Table getMainTable() 58 { 59 return mainTable; 60 } 61 62 public final SQLIdentifier getRangeVariable() 63 { 64 return mainRangeVar; 65 } 66 67 public SQLExpression newFieldExpression(String fieldName) 68 { 69 if (!(mainTable instanceof ClassTable)) 70 throw new JDOUserException("'" + fieldName + "' can't be referenced in " + mainTable.getName() + ": table does not store a persistence-capable class"); 71 72 ClassTable ct = (ClassTable)mainTable; 73 Mapping m; 74 75 if (fieldName.equals("this") && ct instanceof ClassBaseTable) 76 m = ((ClassBaseTable)ct).getIDMapping(); 77 else 78 m = ct.getFieldMapping(fieldName); 79 80 return m.newSQLExpression(qs, this, fieldName); 81 } 82 83 public abstract String referenceColumn(Column col); 84 85 public abstract String toString(); 86 } 87 | Popular Tags |