org.apache.derby.impl.sql.compile
Class MethodCallNode

java.lang.Object
  extended byorg.apache.derby.impl.sql.compile.QueryTreeNode
      extended byorg.apache.derby.impl.sql.compile.JavaValueNode
          extended byorg.apache.derby.impl.sql.compile.MethodCallNode
All Implemented Interfaces:
Visitable
Direct Known Subclasses:
NewInvocationNode, NonStaticMethodCallNode, StaticMethodCallNode

public abstract class MethodCallNode
extends JavaValueNode

A MethodCallNode represents a Java method call. Method calls can be done through DML (as expressions) or through the CALL statement.

Author:
Jeff Lichtman

Field Summary
protected  java.lang.String actualMethodReturnType
           
(package private)  boolean internalCall
          True if this is an internal call, just used to set up a generated method call.
protected  java.lang.String javaClassName
          The name of the class containing the method.
protected  java.lang.reflect.Member method
           
protected  java.lang.String methodName
           
(package private)  java.lang.String[] methodParameterTypes
          The parameter types for the resolved method.
protected  JavaValueNode[] methodParms
           
private  java.lang.String[] procedurePrimitiveArrayType
          For resolution of procedure INOUT/OUT parameters to the primitive form, such as int[].
(package private)  RoutineAliasInfo routineInfo
          For a procedure or function call
protected  JSQLType[] signature
           
 
Fields inherited from class org.apache.derby.impl.sql.compile.JavaValueNode
forCallStatement, jsqlType
 
Fields inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX, beginOffset, endOffset
 
Constructor Summary
MethodCallNode()
           
 
Method Summary
 Visitable accept(Visitor v)
          Accept a visitor, and call v.visit() on child nodes as necessary.
 void addParms(JavaValueNode[] methodParms)
          Add the parameter list.
 void addParms(java.util.Vector parameterList)
          Add the parameter list
protected  boolean areParametersQueryInvariant()
          Return whether or not all of the parameters to this node are QUERY_INVARIANT or CONSTANT.
(package private)  void bindParameters(FromList fromList, SubqueryList subqueryList, java.util.Vector aggregateVector)
          Bind this expression.
 boolean categorize(JBitSet referencedTabs, boolean simplePredsOnly)
          Categorize this predicate.
 void generateOneParameter(ExpressionClassBuilder acb, MethodBuilder mb, int parameterNumber)
          Generate one parameter to the given method call.
 int generateParameters(ExpressionClassBuilder acb, MethodBuilder mb)
          Generate the parameters to the given method call
protected  boolean[] getIsParam()
          Build an array of booleans denoting whether or not a given method parameter is a ?.
 java.lang.String getJavaClassName()
           
 java.lang.String getMethodName()
           
 JavaValueNode[] getMethodParms()
          Get the method parameters.
protected  java.lang.String[] getObjectSignature()
          Build an array of names of the argument types.
private  java.lang.String getObjectTypeName(JSQLType jsqlType)
           
protected  int getOrderableVariantType()
          Return the variant type for the underlying expression.
static java.lang.String getParameterTypeName(JavaValueNode param)
           
(package private)  java.lang.String[] getPrimitiveSignature(boolean castToPrimitiveAsNecessary)
           
 JSQLType[] getSignature()
          Gets the signature of JSQLTypes needed to propagate a work unit from target to source.
private  int getVariantTypeOfParams()
           
 void init(java.lang.Object methodName)
          Initializer for a MethodCallNode
private  java.lang.String[] parseValidateSignature(java.lang.String externalName, int offset, boolean hasDynamicResultSets)
          Parse the user supplied signature for a method and validate it, need to match the number of parameters passed in and match the valid types for the parameter.
 void preprocess(int numTables, FromList outerFromList, SubqueryList outerSubqueryList, PredicateList outerPredicateList)
          Preprocess an expression tree.
 void printSubNodes(int depth)
          Prints the sub-nodes of this object.
 JavaValueNode remapColumnReferencesToExpressions()
          Remap all ColumnReferences in this tree to be clones of the underlying expression.
protected  void resolveMethodCall(java.lang.String javaClassName, boolean staticMethod)
           
 void setClause(int clause)
          Set the clause that this node appears in.
 void setNullParameterInfo(java.lang.String[] parmTypeNames)
          Set the appropriate type information for a null passed as a parameter.
protected  boolean someParametersAreNull()
          Return true if some parameters are null, false otherwise.
(package private)  void throwNoMethodFound(java.lang.String receiverTypeName, java.lang.String[] parmTypeNames, java.lang.String[] primParmTypeNames)
          Build parameters for error message and throw the exception when there is no matching signature found.
 java.lang.String toString()
          Convert this object to a String.
 
Methods inherited from class org.apache.derby.impl.sql.compile.JavaValueNode
bindExpression, castToPrimitive, checkReliability, generate, generateExpression, generateReceiver, generateReceiver, getConstantValueAsObject, getJavaTypeName, getJSQLType, getPrimitiveTypeName, getReceiverExpression, isPrimitiveType, mapToTypeID, markForCallStatement, markReturnValueDiscarded, mustCastToPrimitive, returnValueDiscarded, returnValueToSQLDomain, setJavaTypeName, valueReturnedToSQLDomain
 
Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
bind, convertDefaultNode, debugFlush, debugPrint, executeSchemaName, executeStatementName, formatNodeString, foundString, generate, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContextManager, getCursorInfo, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getNodeFactory, getNodeType, getNullNode, getParameterTypes, getRowEstimate, getSchemaDescriptor, getSchemaDescriptor, getSPSName, getStatementType, getTableDescriptor, getTypeCompiler, init, init, init, init, init, init, init, init, init, init, init, init, init, isAtomic, isInstanceOf, isSessionSchema, isSessionSchema, makeConstantAction, makeResultDescription, makeTableName, needsSavepoint, nodeHeader, optimize, parseQueryText, printLabel, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setContextManager, setEndOffset, setNodeType, setRefActionInfo, treePrint, treePrint, verifyClassExist
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

methodName

protected java.lang.String methodName

javaClassName

protected java.lang.String javaClassName
The name of the class containing the method. May not be known until bindExpression() has been called.

See Also:
JavaValueNode.bindExpression(org.apache.derby.impl.sql.compile.FromList, org.apache.derby.impl.sql.compile.SubqueryList, java.util.Vector), getJavaClassName()

routineInfo

RoutineAliasInfo routineInfo
For a procedure or function call


internalCall

boolean internalCall
True if this is an internal call, just used to set up a generated method call.


procedurePrimitiveArrayType

private java.lang.String[] procedurePrimitiveArrayType
For resolution of procedure INOUT/OUT parameters to the primitive form, such as int[]. May be null.


signature

protected JSQLType[] signature

methodParms

protected JavaValueNode[] methodParms

method

protected java.lang.reflect.Member method

actualMethodReturnType

protected java.lang.String actualMethodReturnType

methodParameterTypes

java.lang.String[] methodParameterTypes
The parameter types for the resolved method.

Constructor Detail

MethodCallNode

public MethodCallNode()
Method Detail

getSignature

public JSQLType[] getSignature()
Gets the signature of JSQLTypes needed to propagate a work unit from target to source.

Returns:
the JSQLType signature

init

public void init(java.lang.Object methodName)
Initializer for a MethodCallNode

Overrides:
init in class QueryTreeNode
Parameters:
methodName - The name of the method to call

getMethodName

public java.lang.String getMethodName()

getJavaClassName

public java.lang.String getJavaClassName()
Returns:
the name of the class that contains the method, null if not known. It may not be known until this node has been bound.

setClause

public void setClause(int clause)
Set the clause that this node appears in.

Overrides:
setClause in class JavaValueNode
Parameters:
clause - The clause that this node appears in.
Returns:
Nothing.

addParms

public void addParms(JavaValueNode[] methodParms)
Add the parameter list. (This flavor is useful when transforming a non-static method call node to a static method call node.)

Parameters:
methodParms - JavaValueNode[]
Returns:
Nothing

addParms

public void addParms(java.util.Vector parameterList)
              throws StandardException
Add the parameter list

Parameters:
parameterList - A Vector of the parameters
Returns:
Nothing
Throws:
StandardException - Thrown on error

printSubNodes

public void printSubNodes(int depth)
Prints the sub-nodes of this object. See QueryTreeNode.java for how tree printing is supposed to work.

Overrides:
printSubNodes in class QueryTreeNode
Parameters:
depth - The depth of this node in the tree
Returns:
Nothing

toString

public java.lang.String toString()
Convert this object to a String. See comments in QueryTreeNode.java for how this should be done for tree printing.

Overrides:
toString in class QueryTreeNode
Returns:
This object as a String

bindParameters

final void bindParameters(FromList fromList,
                          SubqueryList subqueryList,
                          java.util.Vector aggregateVector)
                   throws StandardException
Bind this expression. This means binding the sub-expressions, as well as figuring out what the return type is for this expression.

Parameters:
fromList - The FROM list for the query this expression is in, for binding columns.
subqueryList - The subquery list being built as we find SubqueryNodes
aggregateVector - The aggregate vector being built as we find AggregateNodes
Returns:
this
Throws:
StandardException - Thrown on error

areParametersQueryInvariant

protected boolean areParametersQueryInvariant()
                                       throws StandardException
Return whether or not all of the parameters to this node are QUERY_INVARIANT or CONSTANT. This is useful for VTIs - a VTI is a candidate for materialization if all of its parameters are QUERY_INVARIANT or CONSTANT

Returns:
Whether or not all of the parameters to this node are QUERY_INVARIANT or CONSTANT
Throws:
StandardException - thrown on error

throwNoMethodFound

void throwNoMethodFound(java.lang.String receiverTypeName,
                        java.lang.String[] parmTypeNames,
                        java.lang.String[] primParmTypeNames)
                  throws StandardException
Build parameters for error message and throw the exception when there is no matching signature found.

Parameters:
receiverTypeName - Type name for receiver
parmTypeNames - Type names for parameters as object types
primParmTypeNames - Type names for parameters as primitive types
Returns:
Nothing.
Throws:
StandardException - Thrown on error

preprocess

public void preprocess(int numTables,
                       FromList outerFromList,
                       SubqueryList outerSubqueryList,
                       PredicateList outerPredicateList)
                throws StandardException
Preprocess an expression tree. We do a number of transformations here (including subqueries, IN lists, LIKE and BETWEEN) plus subquery flattening. NOTE: This is done before the outer ResultSetNode is preprocessed.

Specified by:
preprocess in class JavaValueNode
Parameters:
numTables - Number of tables in the DML Statement
outerFromList - FromList from outer query block
outerSubqueryList - SubqueryList from outer query block
outerPredicateList - PredicateList from outer query block
Returns:
Nothing.
Throws:
StandardException - Thrown on error
See Also:
ValueNode.preprocess(int, org.apache.derby.impl.sql.compile.FromList, org.apache.derby.impl.sql.compile.SubqueryList, org.apache.derby.impl.sql.compile.PredicateList)

categorize

public boolean categorize(JBitSet referencedTabs,
                          boolean simplePredsOnly)
                   throws StandardException
Categorize this predicate. Initially, this means building a bit map of the referenced tables for each predicate. If the source of this ColumnReference (at the next underlying level) is not a ColumnReference or a VirtualColumnNode then this predicate will not be pushed down. For example, in: select * from (select 1 from s) a (x) where x = 1 we will not push down x = 1. NOTE: It would be easy to handle the case of a constant, but if the inner SELECT returns an arbitrary expression, then we would have to copy that tree into the pushed predicate, and that tree could contain subqueries and method calls. RESOLVE - revisit this issue once we have views.

Specified by:
categorize in class JavaValueNode
Parameters:
referencedTabs - JBitSet with bit map of referenced FromTables
simplePredsOnly - Whether or not to consider method calls, field references and conditional nodes when building bit map
Returns:
boolean Whether or not source.expression is a ColumnReference or a VirtualColumnNode.
Throws:
StandardException - Thrown on error
See Also:
ValueNode.categorize(org.apache.derby.iapi.util.JBitSet, boolean)

remapColumnReferencesToExpressions

public JavaValueNode remapColumnReferencesToExpressions()
                                                 throws StandardException
Remap all ColumnReferences in this tree to be clones of the underlying expression.

Specified by:
remapColumnReferencesToExpressions in class JavaValueNode
Returns:
JavaValueNode The remapped expression tree.
Throws:
StandardException - Thrown on error
See Also:
ValueNode.remapColumnReferencesToExpressions()

generateParameters

public int generateParameters(ExpressionClassBuilder acb,
                              MethodBuilder mb)
                       throws StandardException
Generate the parameters to the given method call

Parameters:
acb - The ExpressionClassBuilder for the class we're generating
mb - the method the expression will go into
Returns:
Count of arguments to the method.
Throws:
StandardException - Thrown on error

getParameterTypeName

public static java.lang.String getParameterTypeName(JavaValueNode param)
                                             throws StandardException
Throws:
StandardException

generateOneParameter

public void generateOneParameter(ExpressionClassBuilder acb,
                                 MethodBuilder mb,
                                 int parameterNumber)
                          throws StandardException
Generate one parameter to the given method call. This method is overriden by RepStaticMethodCallNode.

Parameters:
acb - The ExpressionClassBuilder for the class we're generating
mb - the method the expression will go into
parameterNumber - Identifies which parameter to generate. 0 based.
Returns:
Nothing
Throws:
StandardException - Thrown on error

setNullParameterInfo

public void setNullParameterInfo(java.lang.String[] parmTypeNames)
                          throws StandardException
Set the appropriate type information for a null passed as a parameter. This method is called after method resolution, when a signature was successfully matched.

Parameters:
parmTypeNames - String[] with the java type names for the parameters as declared by the method
Returns:
Nothing.
Throws:
StandardException - Thrown on error

resolveMethodCall

protected void resolveMethodCall(java.lang.String javaClassName,
                                 boolean staticMethod)
                          throws StandardException
Throws:
StandardException

parseValidateSignature

private java.lang.String[] parseValidateSignature(java.lang.String externalName,
                                                  int offset,
                                                  boolean hasDynamicResultSets)
                                           throws StandardException
Parse the user supplied signature for a method and validate it, need to match the number of parameters passed in and match the valid types for the parameter.

Parameters:
offset - Character offset of first paren
hasDynamicResultSets - Can ResultSet[] parameters be specified.
Returns:
The valid array of types for resolution.
Throws:
StandardException

someParametersAreNull

protected boolean someParametersAreNull()
Return true if some parameters are null, false otherwise.


getObjectSignature

protected java.lang.String[] getObjectSignature()
                                         throws StandardException
Build an array of names of the argument types. These types are biased toward Java objects. That is, if an argument is of SQLType, then we map it to the corresponding Java synonym class (e.g., SQLINT is mapped to 'java.lang.Integer').

Returns:
array of type names
Throws:
StandardException - Thrown on error

getIsParam

protected boolean[] getIsParam()
Build an array of booleans denoting whether or not a given method parameter is a ?.

Returns:
array of booleans denoting wheter or not a given method parameter is a ?.

getObjectTypeName

private java.lang.String getObjectTypeName(JSQLType jsqlType)
                                    throws StandardException
Throws:
StandardException

getPrimitiveSignature

java.lang.String[] getPrimitiveSignature(boolean castToPrimitiveAsNecessary)
                                   throws StandardException
Throws:
StandardException

getOrderableVariantType

protected int getOrderableVariantType()
                               throws StandardException
Return the variant type for the underlying expression. The variant type can be: VARIANT - variant within a scan (non-static field access) SCAN_INVARIANT - invariant within a scan (column references from outer tables) QUERY_INVARIANT - invariant within the life of a query (constant expressions)

Overrides:
getOrderableVariantType in class JavaValueNode
Returns:
The variant type for the underlying expression.
Throws:
StandardException

getVariantTypeOfParams

private int getVariantTypeOfParams()
                            throws StandardException
Throws:
StandardException

getMethodParms

public JavaValueNode[] getMethodParms()
Get the method parameters.

Returns:
The method parameters

accept

public Visitable accept(Visitor v)
                 throws StandardException
Accept a visitor, and call v.visit() on child nodes as necessary.

Specified by:
accept in interface Visitable
Overrides:
accept in class QueryTreeNode
Parameters:
v - the visitor
Throws:
StandardException - on error

Built on Mon 2007-06-04 09:58:47+0400, from revision ???

Apache Derby V10.1 Engine Documentation - Copyright © 1997,2005 The Apache Software Foundation or its licensors, as applicable.