1/*
2 * Copyright (C) 2014 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 com.android.providers.tv.util;
18
19import android.database.DatabaseUtils;
20
21public class SqlParams {
22    private String mTables;
23    private String mSelection;
24    private String[] mSelectionArgs;
25
26    public SqlParams(String tables, String selection, String... selectionArgs) {
27        setTables(tables);
28        setWhere(selection, selectionArgs);
29    }
30
31    public String getTables() {
32        return mTables;
33    }
34
35    public String getSelection() {
36        return mSelection;
37    }
38
39    public String[] getSelectionArgs() {
40        return mSelectionArgs;
41    }
42
43    public void setTables(String tables) {
44        mTables = tables;
45    }
46
47    public void setWhere(String selection, String... selectionArgs) {
48        mSelection = selection;
49        mSelectionArgs = selectionArgs;
50    }
51
52    public void appendWhere(String selection, String... selectionArgs) {
53        mSelection = DatabaseUtils.concatenateWhere(mSelection, selection);
54        if (selectionArgs != null) {
55            mSelectionArgs = DatabaseUtils.appendSelectionArgs(mSelectionArgs, selectionArgs);
56        }
57    }
58}
59