Adnan Begovic | d5fdee9 | 2015-11-13 15:28:21 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The CyanogenMod 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 | |
| 17 | import java.util.ArrayList; |
| 18 | |
| 19 | /** |
| 20 | * Created by adnan on 11/16/15. |
| 21 | */ |
| 22 | public class SettingImageCommands implements CommandExecutor { |
| 23 | private ArrayList<Command> commandHistory = new ArrayList<Command>(); |
| 24 | private String authority; |
| 25 | |
| 26 | public SettingImageCommands(String authority) { |
| 27 | this.authority = authority; |
| 28 | } |
| 29 | |
| 30 | @Override |
| 31 | public void execute() { |
| 32 | for (Command commandWithTimeout : commandHistory) { |
| 33 | commandWithTimeout.run(); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | private void addCommand(Command commandWithTimeout) { |
| 38 | commandWithTimeout.prepend(authority); |
| 39 | commandHistory.add(commandWithTimeout); |
| 40 | } |
| 41 | |
| 42 | public void addQuery(String uri, ArrayList<Setting> settings) { |
| 43 | QueryCommand queryCommand = new QueryCommand(uri, settings); |
| 44 | addCommand(queryCommand); |
| 45 | } |
| 46 | |
| 47 | public void addInsert(String uri, Setting setting) { |
| 48 | InsertCommand insertCommand = new InsertCommand(uri, setting); |
| 49 | addCommand(insertCommand); |
| 50 | } |
| 51 | |
| 52 | public void addRead(String fileName, String uri, ArrayList<Setting> settings) { |
| 53 | ReadCommand readCommand = new ReadCommand(fileName, uri, settings); |
| 54 | addCommand(readCommand); |
| 55 | } |
Adnan Begovic | d5fdee9 | 2015-11-13 15:28:21 -0800 | [diff] [blame] | 56 | } |