db
Interface SqlFunction
public interface SqlFunction
This interface allows InstantDB to add new SQL functions dynamically. Classes which implement this interface can be used to evaluate functions as part of InstantDB SQL expressions. Whenever InstantDB encounters a function, other than an aggregate function, it uses the function name to create an instance of a class of that name. The function name is converted to lowercase. So TO_DATE(...) would create an instance of a class named to_date(). Classes which implement this interface can be placed anywhere on the classpath, or they can be Java 2 extension classes. They can even be added while the database is still running.
Field Summary
static int DATE_FORMAT
          Get special constant DATE_FORMAT.
static int MILLENIUM_BOUNDARY
          Set special constant MILLENIUM_BOUNDARY.
static int TYPE_BLOB
          Parameter type TYPE_BLOB
static int TYPE_BYTE
          Parameter type TYPE_BYTE
static int TYPE_CURRENCY
          Parameter type TYPE_CURRENCY
static int TYPE_DATE
          Parameter type TYPE_DATE
static int TYPE_DOUBLE
          Parameter type TYPE_DOUBLE
static int TYPE_FLOAT
          Parameter type TYPE_FLOAT
static int TYPE_INTEGER
          Parameter type TYPE_INTEGER
static int TYPE_LONG
          Parameter type TYPE_LONG
static int TYPE_STRING
          Parameter type TYPE_STRING
 
Method Summary
 int checkParameters(int[] parameterTypes)
          Allows a function object to check the types of the parameters which will be passed to it when it is asked to evaluate itself.
 java.lang.Object evaluate(java.lang.Object[] parameters)
          Evaluates an function.
 java.lang.Object getSpecialValue(int type)
          Used by InstantDB to fetch database information from a function.
 void setSpecialValue(int type, java.lang.Object value)
          Used by InstantDB to pass database information into a function.
 
Field Detail
TYPE_BYTE
public static final int TYPE_BYTE
Parameter type TYPE_BYTE

TYPE_INTEGER
public static final int TYPE_INTEGER
Parameter type TYPE_INTEGER

TYPE_STRING
public static final int TYPE_STRING
Parameter type TYPE_STRING

TYPE_LONG
public static final int TYPE_LONG
Parameter type TYPE_LONG

TYPE_DATE
public static final int TYPE_DATE
Parameter type TYPE_DATE

TYPE_CURRENCY
public static final int TYPE_CURRENCY
Parameter type TYPE_CURRENCY

TYPE_FLOAT
public static final int TYPE_FLOAT
Parameter type TYPE_FLOAT

TYPE_DOUBLE
public static final int TYPE_DOUBLE
Parameter type TYPE_DOUBLE

TYPE_BLOB
public static final int TYPE_BLOB
Parameter type TYPE_BLOB

MILLENIUM_BOUNDARY
public static final int MILLENIUM_BOUNDARY
Set special constant MILLENIUM_BOUNDARY.

DATE_FORMAT
public static final int DATE_FORMAT
Get special constant DATE_FORMAT.
Method Detail
checkParameters
public int checkParameters(int[] parameterTypes)
throws java.sql.SQLException
Allows a function object to check the types of the parameters which will be passed to it when it is asked to evaluate itself. The parameter types are passed as an int[]. Each entry in the array has the type of one of the parameters. The valid types are defined as constants in this interface. The function must return the type corresponding to its expected evaluation type. The method should throw a SQLException containing an appropriate error message if the parameters are deemed to be incorrect.

evaluate
public java.lang.Object evaluate(java.lang.Object[] parameters)
throws java.sql.SQLException
Evaluates an function. The parameters are passed as an array of Objects. The objects types correspond to one of the following:
  1. java.lang.Integer for TYPE_BYTE and TYPE_INTEGER.
  2. java.lang.Long for TYPE_LONG, TYPE_CURRENCY and TYPE_DATE.
  3. java.lang.Float for TYPE_FLOAT.
  4. java.lanf.Double for TYPE_DOUBLE.
  5. java.lang.String for TYPE_STRING.
  6. byte[] for TYPE_BLOB.
The function must return the an object of the type determined by the result of checkParameters method. The method should throw a SQLException containing an appropriate error message if the evaluation cannot complete.

setSpecialValue
public void setSpecialValue(int type,
java.lang.Object value)
throws java.sql.SQLException
Used by InstantDB to pass database information into a function. The type parameter specifies the information that is being provided.

getSpecialValue
public java.lang.Object getSpecialValue(int type)
throws java.sql.SQLException
Used by InstantDB to fetch database information from a function. The type parameter specifies the information that is being provided. Returns a null value if the function cannot provide the requested information.