Java Code Examples for org.sqlite.Function

The following examples show how to use org.sqlite.Function. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: v-mock   Source File: DataBaseUtils.java    License: MIT License 5 votes vote down vote up
/**
 * 给指定的connection创建REGEXP支持
 *
 * @param connection 链接
 */
@SneakyThrows
public static void createRegexpFun(Connection connection) {
    Function.create(connection, "REGEXP", new Function() {
        @Override
        protected void xFunc() throws SQLException {
            String expression = value_text(0);
            String value = value_text(1);
            // null to empty
            value = value == null ? EMPTY : value;
            Pattern pattern = Pattern.compile(expression);
            result(pattern.matcher(value).find() ? 1 : 0);
        }
    });
}
 
Example 2
Source Project: geopackage-java   Source File: RTreeIndexExtension.java    License: MIT License 5 votes vote down vote up
/**
 * Create the function for the connection
 * 
 * @param name
 *            function name
 * @param function
 *            geometry function
 */
private void createFunction(String name, GeometryFunction function) {
	try {
		Function.create(getGeoPackage().getConnection().getConnection(),
				name, function);
	} catch (SQLException e) {
		log.log(Level.SEVERE, "Failed to create function: " + name, e);
	}
}