org.sqlite.Function Java Examples

The following examples show how to use org.sqlite.Function. 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 File: DataBaseUtils.java    From v-mock with 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 File: RTreeIndexExtension.java    From geopackage-java with 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);
	}
}