Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.hsqldb
Class Function  view Function download Function.java

java.lang.Object
  extended byorg.hsqldb.Function

class Function
extends java.lang.Object

Provides services to evaluate Java methods in the context of SQL function and stored procedure calls.

Version:
1.7.0

Field Summary
private  boolean[] bArgNullable
           
private  boolean bConnection
           
private  Session cSession
           
private  Expression[] eArg
           
private  int iArgCount
           
private  int[] iArgType
           
private  int iReturnType
           
private  boolean isIdentityFunction
           
private static java.util.Hashtable methodCache
           
private  java.lang.reflect.Method mMethod
           
private  java.lang.Object[] oArg
           
private  java.lang.String sFunction
           
 
Constructor Summary
(package private) Function(java.lang.String function, Session session)
          Constructs a new Function object with the given function call name and using the specified Session context.
 
Method Summary
(package private)  void checkResolved()
          Checks each of this object's arguments for resolution, throwing a SQLException if any arguments have not yet been resolved.
(package private)  int getArgCount()
          Retrieves the number of parameters that must be supplied to evaluate this Function object from SQL.
(package private)  int getArgType(int i)
          Retrieves the java.sql.Types type of the argument at the specified offset in this Function object's paramter list
(package private)  int getReturnType()
          Retrieves the java.sql.Types type of this Function object's return type
(package private)  java.lang.Object getValue()
          Retrieves the value this Function evaluates to, given the current state of this object's resolved 55 TableFilter, if any, and any mapping of expressions to this Function's parameter list that has been performed via {link #setArgument(int,Expression) setArgument}.
(package private)  void resolve(TableFilter f)
          Resolves the arguments supplied to this Function object against the specified TableFilter.
(package private)  void setArgument(int i, Expression e)
          Binds the specified expression to the specified argument in this Function object's paramter list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cSession

private Session cSession

sFunction

private java.lang.String sFunction

mMethod

private java.lang.reflect.Method mMethod

iReturnType

private int iReturnType

iArgCount

private int iArgCount

iArgType

private int[] iArgType

bArgNullable

private boolean[] bArgNullable

oArg

private java.lang.Object[] oArg

eArg

private Expression[] eArg

bConnection

private boolean bConnection

isIdentityFunction

private boolean isIdentityFunction

methodCache

private static java.util.Hashtable methodCache
Constructor Detail

Function

Function(java.lang.String function,
         Session session)
   throws java.sql.SQLException
Constructs a new Function object with the given function call name and using the specified Session context.

The call name is the fully qualified name of a static Java method, as opposed to the method's canonical signature. That is, the name is of the form "package.class.method." This implies that Java methods with the same fully qualified name but different signatures cannot be used properly as HSQLDB SQL functions or stored procedures. For instance, it is impossible to call both System.getProperty(String) and System.getProperty(String,String) under this arrangement, because the HSQLDB Function object is unable to differentiate between the two; it simply chooses the first method matching the FQN in the array of methods obtained from calling getMethods() on an instance of the Class indicated in the FQN, hiding all other methods with the same FQN.

The function FQN must match at least one static Java method FQN in the specified class or construction cannot procede and a SQLException is thrown.

The Session paramter is the connected context in which this Function object will evaluate. If it is determined that the connected user does not have the right to evaluate this Function, construction cannot proceed and a SQLException is thrown.

Method Detail

getValue

java.lang.Object getValue()
                    throws java.sql.SQLException
Retrieves the value this Function evaluates to, given the current state of this object's resolved 55 TableFilter, if any, and any mapping of expressions to this Function's parameter list that has been performed via {link #setArgument(int,Expression) setArgument}.


getArgCount

int getArgCount()
Retrieves the number of parameters that must be supplied to evaluate this Function object from SQL.

This value may be different than the number of parameters of the underlying Java method. This is because HSQLDB automatically detects if the first parameter is of type java.sql.Connection, and supplies a live Connection object constructed from the evaluating session context if so.


resolve

void resolve(TableFilter f)
       throws java.sql.SQLException
Resolves the arguments supplied to this Function object against the specified TableFilter.


checkResolved

void checkResolved()
             throws java.sql.SQLException
Checks each of this object's arguments for resolution, throwing a SQLException if any arguments have not yet been resolved.


getArgType

int getArgType(int i)
Retrieves the java.sql.Types type of the argument at the specified offset in this Function object's paramter list


getReturnType

int getReturnType()
Retrieves the java.sql.Types type of this Function object's return type


setArgument

void setArgument(int i,
                 Expression e)
Binds the specified expression to the specified argument in this Function object's paramter list.