Brett Chabot | e278a5b | 2010-06-01 16:20:14 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2010 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 | |
| 17 | package com.android.tradefed.config; |
| 18 | |
| 19 | import java.io.File; |
| 20 | import java.io.PrintStream; |
| 21 | |
| 22 | /** |
| 23 | * |
| 24 | */ |
| 25 | public interface IConfigurationFactory { |
| 26 | |
| 27 | /** |
| 28 | * Gets the built-in {@link IConfiguration} with given name. |
| 29 | * |
| 30 | * @param name the unique name of the {@link IConfiguration} |
| 31 | * @return the {@link IConfiguration} |
| 32 | * @throws ConfigurationException if the {@link IConfiguration} could not be loaded. |
| 33 | */ |
| 34 | public IConfiguration getConfiguration(String name) throws ConfigurationException; |
| 35 | |
| 36 | /** |
| 37 | * Create the {@link IConfiguration} from given XML file. |
| 38 | * |
| 39 | * @param xmlFile the {@link File} to read configuration from |
| 40 | * @return the loaded {@link IConfiguration}. |
| 41 | * @throws {@link ConfigurationException} if configuration could not be loaded |
| 42 | */ |
| 43 | public IConfiguration createConfigurationFromXML(File xmlFile) throws ConfigurationException; |
| 44 | |
| 45 | /** |
| 46 | * Create the {@link IConfiguration} from command line arguments. |
| 47 | * <p/> |
| 48 | * Expected format is [options] <configuration name>. |
| 49 | * |
| 50 | * @param args the command line arguments |
| 51 | * @return the loaded {@link IConfiguration}. The delegate object {@link Option} fields have |
| 52 | * been populated with values in args. |
| 53 | * @throws {@link ConfigurationException} if configuration could not be loaded |
| 54 | */ |
| 55 | public IConfiguration createConfigurationFromArgs(String[] args) throws ConfigurationException; |
| 56 | |
| 57 | /** |
| 58 | * Populate given configuration with arg values |
| 59 | * |
| 60 | * @param args |
| 61 | * @param config |
| 62 | * @return |
| 63 | * @throws ConfigurationException |
| 64 | */ |
| 65 | public IConfiguration populateConfigWithArgs(String[] args, IConfiguration config) |
| 66 | throws ConfigurationException; |
| 67 | |
| 68 | /** |
| 69 | * Prints help output. |
| 70 | * <p/> |
| 71 | * If a configuration argument is specified prints the help info specific to that |
| 72 | * configuration. Otherwise prints a generic help info, and lists all available configurations. |
| 73 | * |
| 74 | * @param args the command line arguments |
| 75 | * @param out the {@link PrintStream} to dump output to |
| 76 | */ |
| 77 | public void printHelp(String[] args, PrintStream out); |
| 78 | |
| 79 | } |