1 21 22 package org.apache.derby.impl.sql.compile; 23 24 import org.apache.derby.iapi.services.monitor.Monitor; 25 26 import org.apache.derby.iapi.services.compiler.MethodBuilder; 27 28 import org.apache.derby.iapi.services.sanity.SanityManager; 29 30 import org.apache.derby.iapi.error.StandardException; 31 32 import org.apache.derby.iapi.sql.dictionary.DataDictionary; 33 import org.apache.derby.iapi.reference.SQLState; 34 35 import org.apache.derby.iapi.services.loader.ClassInspector; 36 37 import org.apache.derby.iapi.store.access.Qualifier; 38 39 import org.apache.derby.impl.sql.compile.ExpressionClassBuilder; 40 import org.apache.derby.iapi.sql.compile.CompilerContext; 41 42 import org.apache.derby.iapi.util.JBitSet; 43 44 import java.lang.reflect.Member ; 45 import java.lang.reflect.Modifier ; 46 47 import java.util.Vector ; 48 49 56 57 public final class StaticClassFieldReferenceNode extends JavaValueNode 58 { 59 62 private String fieldName; 63 64 65 private String javaClassName; 66 private boolean classNameDelimitedIdentifier; 67 68 71 private Member field; 72 73 79 public void init(Object javaClassName, Object fieldName, Object classNameDelimitedIdentifier) 80 { 81 this.fieldName = (String ) fieldName; 82 this.javaClassName = (String ) javaClassName; 83 this.classNameDelimitedIdentifier = ((Boolean ) classNameDelimitedIdentifier).booleanValue(); 84 } 85 86 99 100 public JavaValueNode bindExpression(FromList fromList, SubqueryList subqueryList, 101 Vector aggregateVector) 102 throws StandardException 103 { 104 ClassInspector classInspector = getClassFactory().getClassInspector(); 105 106 107 if (((getCompilerContext().getReliability() & CompilerContext.INTERNAL_SQL_ILLEGAL) != 0) 108 || !javaClassName.startsWith("java.sql.")) { 109 110 throw StandardException.newException(SQLState.LANG_SYNTAX_ERROR, javaClassName + "::" + fieldName); 111 } 112 113 javaClassName = verifyClassExist(javaClassName, ! classNameDelimitedIdentifier); 114 115 118 field = classInspector.findPublicField(javaClassName, 119 fieldName, 120 true); 121 122 setJavaTypeName( classInspector.getType(field) ); 123 124 return this; 125 126 } 127 128 141 public void preprocess(int numTables, 142 FromList outerFromList, 143 SubqueryList outerSubqueryList, 144 PredicateList outerPredicateList) 145 throws StandardException 146 { 147 } 148 149 173 public boolean categorize(JBitSet referencedTabs, boolean simplePredsOnly) 174 { 175 return true; 176 } 177 178 186 public JavaValueNode remapColumnReferencesToExpressions() 187 throws StandardException 188 { 189 return this; 190 } 191 192 204 protected int getOrderableVariantType() 205 { 206 if (SanityManager.DEBUG) 207 { 208 SanityManager.ASSERT(field != null, 209 "field is expected to be non-null"); 210 } 211 214 if (Modifier.isFinal(field.getModifiers())) 215 { 216 return Qualifier.CONSTANT; 217 } 218 else 219 { 220 return Qualifier.VARIANT; 221 } 222 } 223 224 229 public void generateExpression(ExpressionClassBuilder acb, 230 MethodBuilder mb) 231 throws StandardException 232 { 233 238 239 mb.getStaticField(field.getDeclaringClass().getName(), 240 fieldName, 241 getJavaTypeName()); 242 } 243 244 } 245 | Popular Tags |