1/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.database.sqlite;
18
19/**
20 * Describes a custom SQL function.
21 *
22 * @hide
23 */
24public final class SQLiteCustomFunction {
25    public final String name;
26    public final int numArgs;
27    public final SQLiteDatabase.CustomFunction callback;
28
29    /**
30     * Create custom function.
31     *
32     * @param name The name of the sqlite3 function.
33     * @param numArgs The number of arguments for the function, or -1 to
34     * support any number of arguments.
35     * @param callback The callback to invoke when the function is executed.
36     */
37    public SQLiteCustomFunction(String name, int numArgs,
38            SQLiteDatabase.CustomFunction callback) {
39        if (name == null) {
40            throw new IllegalArgumentException("name must not be null.");
41        }
42
43        this.name = name;
44        this.numArgs = numArgs;
45        this.callback = callback;
46    }
47
48    // Called from native.
49    @SuppressWarnings("unused")
50    private void dispatchCallback(String[] args) {
51        callback.callback(args);
52    }
53}
54