View Javadoc

1   /***
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.cli;
18  
19  import java.util.Properties;
20  
21  /***
22   * A class that implements the <code>CommandLineParser</code> interface 
23   * can parse a String array according to the {@link Options} specified
24   * and return a {@link CommandLine}.
25   *
26   * @author John Keyes (john at integralsource.com)
27   */
28  public interface CommandLineParser {
29  
30      /***
31       * Parse the arguments according to the specified options.
32       *
33       * @param options the specified Options
34       * @param arguments the command line arguments
35       * @return the list of atomic option and value tokens
36       *
37       * @throws ParseException if there are any problems encountered
38       * while parsing the command line tokens.
39       */
40      CommandLine parse(Options options, String[] arguments)
41                 throws ParseException;
42  
43      /***
44       * Parse the arguments according to the specified options and
45       * properties.
46       *
47       * @param options the specified Options
48       * @param arguments the command line arguments
49       * @param properties command line option name-value pairs
50       * @return the list of atomic option and value tokens
51       *
52       * @throws ParseException if there are any problems encountered
53       * while parsing the command line tokens.
54       */
55      /* To maintain binary compatibility, this is commented out. 
56         It is still in the abstract Parser class, so most users will 
57         still reap the benefit. 
58      CommandLine parse(Options options, String[] arguments, 
59                        Properties properties)
60                 throws ParseException;
61       */
62  
63      /***
64       * Parse the arguments according to the specified options.
65       *
66       * @param options the specified Options
67       * @param arguments the command line arguments
68       * @param stopAtNonOption specifies whether to continue parsing the
69       * arguments if a non option is encountered.
70       *
71       * @return the list of atomic option and value tokens
72       * @throws ParseException if there are any problems encountered
73       * while parsing the command line tokens.
74       */
75      CommandLine parse(Options options, String[] arguments, 
76                        boolean stopAtNonOption)
77                 throws ParseException;
78  
79      /***
80       * Parse the arguments according to the specified options and
81       * properties.
82       *
83       * @param options the specified Options
84       * @param arguments the command line arguments
85       * @param properties command line option name-value pairs
86       * @param stopAtNonOption specifies whether to continue parsing the
87       *
88       * @return the list of atomic option and value tokens
89       * @throws ParseException if there are any problems encountered
90       * while parsing the command line tokens.
91       */
92      /* To maintain binary compatibility, this is commented out. 
93         It is still in the abstract Parser class, so most users will 
94         still reap the benefit. 
95      CommandLine parse(Options options, String[] arguments, 
96                        Properties properties, boolean stopAtNonOption)
97                 throws ParseException;
98       */
99  }