org.sqlite.udf
Class Function

java.lang.Object
  extended by org.sqlite.callback.Callback
      extended by org.sqlite.callback.NamedCallback
          extended by org.sqlite.udf.Function
Direct Known Subclasses:
AggregateFunction, ScalarFunction

public abstract class Function
extends NamedCallback

User-Defined function class.

See Also:
Create Or Redefine SQL Functions, JdbcConnection.createFunction(Function), JdbcConnection.dropFunction(Function)

Field Summary
protected  int argc
          the number of arguments that the SQL function or aggregate takes
 
Constructor Summary
protected Function(java.lang.String name)
          invoke Function(String, -1) constructor.
protected Function(java.lang.String name, int argc)
          create Function object with SQLITE_UTF8.
protected Function(java.lang.String name, int argc, int enc)
          create Function object.
 
Method Summary
 int getArgumentCount()
          Returns the number of arguments that the SQL function or aggregate takes.
 void register(SWIGTYPE_p_sqlite3 db)
          invoke sqlite3_create_function() function and this object is registered in the database.
WARNING! Do not use this method because it is called internally.
 void unregister(SWIGTYPE_p_sqlite3 db)
          Unregister this object from the database.
WARNING! Do not use this method because it is called internally.
protected abstract  void xFunc(Context ctx)
          Called from the sqlite3_step() function.
protected  void xFunc(long context, int argc, long value)
          Called from the sqlite3_step() function.
 
Methods inherited from class org.sqlite.callback.NamedCallback
getEncoding, getName
 
Methods inherited from class org.sqlite.callback.Callback
delete, isRegistered
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

argc

protected final int argc
the number of arguments that the SQL function or aggregate takes

Constructor Detail

Function

protected Function(java.lang.String name)
invoke Function(String, -1) constructor.

Parameters:
name - the function name
See Also:
Function(java.lang.String, int)

Function

protected Function(java.lang.String name,
                   int argc)
create Function object with SQLITE_UTF8.

Parameters:
name - the function name
argc - the number of arguments that the SQL function or aggregate takes.
See Also:
NamedCallback.NamedCallback(java.lang.String)

Function

protected Function(java.lang.String name,
                   int argc,
                   int enc)
create Function object.

Parameters:
name - the function name
argc - the number of arguments that the SQL function or aggregate takes.
enc - the specifies what text encoding this function prefers for its parameters.
See Also:
Text Encodings, NamedCallback.NamedCallback(java.lang.String, int)
Method Detail

register

public final void register(SWIGTYPE_p_sqlite3 db)
                    throws java.sql.SQLException
invoke sqlite3_create_function() function and this object is registered in the database.
WARNING! Do not use this method because it is called internally.

Specified by:
register in class Callback
Parameters:
db - the database handle.
Throws:
java.sql.SQLException - When the return value of the sqlite3_create_function() function is not SQLITE_OK.
See Also:
Database.createFunction(Function)

unregister

public final void unregister(SWIGTYPE_p_sqlite3 db)
                      throws java.sql.SQLException
Unregister this object from the database.
WARNING! Do not use this method because it is called internally.

Specified by:
unregister in class Callback
Parameters:
db - the database handle.
Throws:
java.sql.SQLException - When the return value of the sqlite3_create_function() function is not SQLITE_OK.
See Also:
Database.dropFunction(Function)

getArgumentCount

public int getArgumentCount()
Returns the number of arguments that the SQL function or aggregate takes.

Returns:
the number of arguments that the SQL function or aggregate takes

xFunc

protected final void xFunc(long context,
                           int argc,
                           long value)
Called from the sqlite3_step() function.

Parameters:
context - the sqlite3_context* value
argc - the number of arguments
value - the sqlite3_value** value
See Also:
xFunc(org.sqlite.udf.Context)

xFunc

protected abstract void xFunc(Context ctx)
                       throws java.sql.SQLException
Called from the sqlite3_step() function.

Parameters:
ctx - sqlite3_context wrapper object
Throws:
java.sql.SQLException