org.sqlite.udf
Class Context

java.lang.Object
  extended by org.sqlite.udf.Context

public class Context
extends java.lang.Object

sqlite3_context and sqlite3_value wrapper class.

See Also:
SQL Function Context Object, Dynamically Typed Value Object

Constructor Summary
Context(long ctx)
          invoke Context(long, 0, 0) constructor.
Context(long ctx, int argc, long value)
          invoke Context(SWIGTYPE_p_sqlite3_context, int, SWIGTYPE_p_p_Mem) constructor.
Context(SWIGTYPE_p_sqlite3_context ctx, int argc, SWIGTYPE_p_p_Mem value)
          create Context object.
 
Method Summary
 int getArgumentCount()
          Returns the number of arguments.
 java.lang.Object getAuxData(int parameterIndex)
          invoke sqlite3_get_auxdata() function.
 SWIGTYPE_p_void getBlob(int parameterIndex)
          invoke sqlite3_value_blob() function.
 int getByteLength(int parameterIndex)
          invoke sqlite3_value_bytes() function.
 byte[] getBytes(int parameterIndex)
          invoke sqlite3_value_blob() function.
 java.sql.Date getDate(int parameterIndex)
          invoke sqlite3_value_text() function.
 SWIGTYPE_p_sqlite3 getDbHandle()
          invoke sqlite3_context_db_handle() function.
 double getDouble(int parameterIndex)
          invoke sqlite3_value_double() function.
 int getInt(int parameterIndex)
          invoke sqlite3_value_int() function.
 long getLong(int parameterIndex)
          invoke sqlite3_value_int64() function.
 SWIGTYPE_p_Mem getSQLite3ValuePtr(int parameterIndex)
          Returns the value of sqlite3_value*.
 java.lang.String getString(int parameterIndex)
          invoke sqlite3_value_text() function.
 java.sql.Time getTime(int parameterIndex)
          invoke sqlite3_value_text() function.
 java.sql.Timestamp getTimestamp(int parameterIndex)
          invoke sqlite3_value_text() function.
 int getValueNumericType(int parameterIndex)
          invoke sqlite3_value_numeric_type() function.
 int getValueType(int parameterIndex)
          invoke sqlite3_value_type() function.
 boolean hasValues()
          true if the getArgumentCount() is greater than 0, and the sqlite3_value** wrapper object is not null.
 void result(boolean x)
          invoke sqlite3_result_int() function.
 void result(byte[] x)
          invoke sqlite3_result_blob() function.
 void result(byte[] x, int len)
          invoke sqlite3_result_blob() function.
 void result(java.sql.Date x)
          invoke sqlite3_result_text() function.
 void result(double x)
          invoke sqlite3_result_double() function.
 void result(int x)
          invoke sqlite3_result_int() function.
 void result(long x)
          invoke sqlite3_result_int64() function.
 void result(java.lang.String x)
          invoke sqlite3_result_text() function.
 void result(SWIGTYPE_p_Mem x)
          invoke sqlite3_result_value() function.
 void result(SWIGTYPE_p_void x, int bytes)
          invoke sqlite3_result_blob() function.
 void result(java.sql.Time x)
          invoke sqlite3_result_text() function.
 void result(java.sql.Timestamp x)
          invoke sqlite3_result_text() function.
 void resultError(java.lang.String x)
          invoke sqlite3_result_error() function.
 void resultErrorCode(int x)
          invoke sqlite3_result_error_code() function.
 void resultErrorNoMemory()
          invoke sqlite3_result_error_nomem() function.
 void resultErrorTooBig()
          invoke sqlite3_result_error_toobig() function.
 void resultNull()
          invoke sqlite3_result_null() function.
 void resultZeroBlob(int bytes)
          invoke sqlite3_result_zeroblob() function.
 void setAuxData(int parameterIndex, java.lang.Object auxdata)
          invoke sqlite3_set_auxdata() function.
The "auxdata" is some auxiliary data that can be associated with a constant argument to a function.
protected  void validateParamaeterIndexRange(int parameterIndex)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Context

public Context(long ctx)
invoke Context(long, 0, 0) constructor.

Parameters:
ctx - the sqlite3_context* value

Context

public Context(long ctx,
               int argc,
               long value)
invoke Context(SWIGTYPE_p_sqlite3_context, int, SWIGTYPE_p_p_Mem) constructor.

Parameters:
ctx - the sqlite3_context* value
argc - the number of arguments
value - the sqlite3_value** value

Context

public Context(SWIGTYPE_p_sqlite3_context ctx,
               int argc,
               SWIGTYPE_p_p_Mem value)
create Context object.

Parameters:
ctx - the sqlite3_context* wrapper object
argc - the number of arguments
value - the sqlite3_value** wrapper object
Method Detail

getArgumentCount

public int getArgumentCount()
Returns the number of arguments.

Returns:
the number of arguments

hasValues

public boolean hasValues()
true if the getArgumentCount() is greater than 0, and the sqlite3_value** wrapper object is not null.

Returns:
true if the getArgumentCount() is greater than 0, and the sqlite3_value** wrapper object is not null.

result

public void result(SWIGTYPE_p_void x,
                   int bytes)
invoke sqlite3_result_blob() function.

Parameters:
x - the result value
bytes - the number of bytes
See Also:
Setting The Result Of An SQL Function

result

public void result(byte[] x)
invoke sqlite3_result_blob() function.

Parameters:
x - the result value
See Also:
Setting The Result Of An SQL Function

result

public void result(byte[] x,
                   int len)
invoke sqlite3_result_blob() function.

Parameters:
x - the result value
len - the number of bytes
See Also:
Setting The Result Of An SQL Function

result

public void result(double x)
invoke sqlite3_result_double() function.

Parameters:
x - the result value
See Also:
Setting The Result Of An SQL Function

result

public void result(int x)
invoke sqlite3_result_int() function.

Parameters:
x - the result value
See Also:
Setting The Result Of An SQL Function

result

public void result(long x)
invoke sqlite3_result_int64() function.

Parameters:
x - the result value
See Also:
Setting The Result Of An SQL Function

result

public void result(boolean x)
invoke sqlite3_result_int() function.

Parameters:
x - the result value.
See Also:
Setting The Result Of An SQL Function

result

public void result(java.lang.String x)
invoke sqlite3_result_text() function.

Parameters:
x - the result value
See Also:
Setting The Result Of An SQL Function

result

public void result(SWIGTYPE_p_Mem x)
invoke sqlite3_result_value() function.

Parameters:
x - the result value
See Also:
Setting The Result Of An SQL Function

result

public void result(java.sql.Date x)
invoke sqlite3_result_text() function.

Parameters:
x - the result value
See Also:
Setting The Result Of An SQL Function

result

public void result(java.sql.Time x)
invoke sqlite3_result_text() function.

Parameters:
x - the result value
See Also:
Setting The Result Of An SQL Function

result

public void result(java.sql.Timestamp x)
invoke sqlite3_result_text() function.

Parameters:
x - the result value
See Also:
Setting The Result Of An SQL Function

resultError

public void resultError(java.lang.String x)
invoke sqlite3_result_error() function.

Parameters:
x - the result value
See Also:
Setting The Result Of An SQL Function

resultNull

public void resultNull()
invoke sqlite3_result_null() function.

See Also:
Setting The Result Of An SQL Function

resultErrorCode

public void resultErrorCode(int x)
invoke sqlite3_result_error_code() function.

Parameters:
x - the result error code
See Also:
Setting The Result Of An SQL Function

resultErrorNoMemory

public void resultErrorNoMemory()
invoke sqlite3_result_error_nomem() function.

See Also:
Setting The Result Of An SQL Function

resultErrorTooBig

public void resultErrorTooBig()
invoke sqlite3_result_error_toobig() function.

See Also:
Setting The Result Of An SQL Function

resultZeroBlob

public void resultZeroBlob(int bytes)
invoke sqlite3_result_zeroblob() function.

Parameters:
bytes - the number of bytes
See Also:
Setting The Result Of An SQL Function

getBlob

public SWIGTYPE_p_void getBlob(int parameterIndex)
                        throws java.sql.SQLException
invoke sqlite3_value_blob() function.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
pointer of BLOB object
Throws:
java.sql.SQLException - When the parameterIndex is not valid.
See Also:
Obtaining SQL Function Parameter Values

getByteLength

public int getByteLength(int parameterIndex)
                  throws java.sql.SQLException
invoke sqlite3_value_bytes() function.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
the number of bytes
Throws:
java.sql.SQLException - When the parameterIndex is not valid.
See Also:
Obtaining SQL Function Parameter Values

getBytes

public byte[] getBytes(int parameterIndex)
                throws java.sql.SQLException
invoke sqlite3_value_blob() function.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
value of byte arrays
Throws:
java.sql.SQLException - When the parameterIndex is not valid.
See Also:
Obtaining SQL Function Parameter Values

getDouble

public double getDouble(int parameterIndex)
                 throws java.sql.SQLException
invoke sqlite3_value_double() function.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
value of double
Throws:
java.sql.SQLException - When the parameterIndex is not valid.
See Also:
Obtaining SQL Function Parameter Values

getInt

public int getInt(int parameterIndex)
           throws java.sql.SQLException
invoke sqlite3_value_int() function.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
value of integer
Throws:
java.sql.SQLException - When the parameterIndex is not valid.
See Also:
Obtaining SQL Function Parameter Values

getLong

public long getLong(int parameterIndex)
             throws java.sql.SQLException
invoke sqlite3_value_int64() function.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
value of long
Throws:
java.sql.SQLException - When the parameterIndex is not valid.
See Also:
Obtaining SQL Function Parameter Values

getString

public java.lang.String getString(int parameterIndex)
                           throws java.sql.SQLException
invoke sqlite3_value_text() function.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
value of string
Throws:
java.sql.SQLException - When the parameterIndex is not valid.
See Also:
Obtaining SQL Function Parameter Values

getDate

public java.sql.Date getDate(int parameterIndex)
                      throws java.sql.SQLException
invoke sqlite3_value_text() function.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
new Date(SQLite3.parseDate(String))
Throws:
java.sql.SQLException - When the parameterIndex is not valid.
See Also:
Obtaining SQL Function Parameter Values, SQLite3.parseDate(String)

getTime

public java.sql.Time getTime(int parameterIndex)
                      throws java.sql.SQLException
invoke sqlite3_value_text() function.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
new Time(SQLite3.parseTime(String))
Throws:
java.sql.SQLException - When the parameterIndex is not valid.
See Also:
Obtaining SQL Function Parameter Values, SQLite3.parseTime(String)

getTimestamp

public java.sql.Timestamp getTimestamp(int parameterIndex)
                                throws java.sql.SQLException
invoke sqlite3_value_text() function.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
new Timestamp(SQLite3.parseTimestamp(String))
Throws:
java.sql.SQLException - When the parameterIndex is not valid.
See Also:
Obtaining SQL Function Parameter Values, SQLite3.parseTimestamp(String)

getValueType

public int getValueType(int parameterIndex)
                 throws java.sql.SQLException
invoke sqlite3_value_type() function.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
the type of value
Throws:
java.sql.SQLException - When the parameterIndex is not valid.
See Also:
Obtaining SQL Function Parameter Values

getValueNumericType

public int getValueNumericType(int parameterIndex)
                        throws java.sql.SQLException
invoke sqlite3_value_numeric_type() function.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
attempts to apply numeric affinity to the value.
Throws:
java.sql.SQLException - When the parameterIndex is not valid.
See Also:
Obtaining SQL Function Parameter Values

validateParamaeterIndexRange

protected void validateParamaeterIndexRange(int parameterIndex)
                                     throws java.sql.SQLException
Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Throws:
java.sql.SQLException - When the parameterIndex is not valid.

getSQLite3ValuePtr

public SWIGTYPE_p_Mem getSQLite3ValuePtr(int parameterIndex)
                                  throws java.sql.SQLException
Returns the value of sqlite3_value*.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
the value of sqlite3_value*.
Throws:
java.sql.SQLException - When the parameterIndex is not valid.

getAuxData

public java.lang.Object getAuxData(int parameterIndex)
                            throws java.sql.SQLException
invoke sqlite3_get_auxdata() function.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
Returns:
the value of sqlite3_get_auxdata().
Throws:
java.sql.SQLException - When the parameterIndex is not valid.
See Also:
Function Auxiliary Data

setAuxData

public void setAuxData(int parameterIndex,
                       java.lang.Object auxdata)
                throws java.sql.SQLException
invoke sqlite3_set_auxdata() function.
The "auxdata" is some auxiliary data that can be associated with a constant argument to a function.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
auxdata - the meta-data for the N-th argument of the application-defined function.
Throws:
java.sql.SQLException - When the parameterIndex is not valid.
See Also:
Function Auxiliary Data

getDbHandle

public SWIGTYPE_p_sqlite3 getDbHandle()
invoke sqlite3_context_db_handle() function.

Returns:
a copy of the pointer to the database connection (the 1st parameter) of the the sqlite3_create_function() and sqlite3_create_function16() routines that originally registered the application defined function
See Also:
Database Connection For Functions