Skip to content

Commit 745d1a5

Browse files
author
John Keyes
committed
javadoc updates
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/cli/trunk@129805 13f79535-47bb-0310-9956-ffa450edef68
1 parent dde6993 commit 745d1a5

15 files changed

Lines changed: 458 additions & 74 deletions

src/java/org/apache/commons/cli/AlreadySelectedException.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,22 @@
5858
* <http://www.apache.org/>.
5959
*
6060
*/
61-
6261
package org.apache.commons.cli;
6362

64-
/** <p>Exception thrown when more than one option in an option group
63+
/**
64+
* <p>Thrown when more than one option in an option group
6565
* has been provided.</p>
6666
*
67-
* @author John Keyes (john @ integralsource.com)
68-
* @version $Revision: 1.4 $
67+
* @author John Keyes ( jbjk at mac.com )
68+
* @see ParseException
6969
*/
7070
public class AlreadySelectedException extends ParseException {
7171

72-
/** Construct a new Exception with a message
72+
/**
73+
* <p>Construct a new <code>AlreadySelectedException</code>
74+
* with the specified detail message.</p>
7375
*
74-
* @param message Explanation of the exception
76+
* @param message the detail message
7577
*/
7678
public AlreadySelectedException( String message ) {
7779
super( message );
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,92 @@
1+
/*
2+
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//cli/src/java/org/apache/commons/cli/BasicParser.java,v 1.2 2002/08/26 20:15:02 jkeyes Exp $
3+
* $Revision: 1.2 $
4+
* $Date: 2002/08/26 20:15:02 $
5+
*
6+
* ====================================================================
7+
*
8+
* The Apache Software License, Version 1.1
9+
*
10+
* Copyright (c) 1999-2001 The Apache Software Foundation. All rights
11+
* reserved.
12+
*
13+
* Redistribution and use in source and binary forms, with or without
14+
* modification, are permitted provided that the following conditions
15+
* are met:
16+
*
17+
* 1. Redistributions of source code must retain the above copyright
18+
* notice, this list of conditions and the following disclaimer.
19+
*
20+
* 2. Redistributions in binary form must reproduce the above copyright
21+
* notice, this list of conditions and the following disclaimer in
22+
* the documentation and/or other materials provided with the
23+
* distribution.
24+
*
25+
* 3. The end-user documentation included with the redistribution, if
26+
* any, must include the following acknowlegement:
27+
* "This product includes software developed by the
28+
* Apache Software Foundation (http://www.apache.org/)."
29+
* Alternately, this acknowlegement may appear in the software itself,
30+
* if and wherever such third-party acknowlegements normally appear.
31+
*
32+
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
33+
* Foundation" must not be used to endorse or promote products derived
34+
* from this software without prior written permission. For written
35+
* permission, please contact apache@apache.org.
36+
*
37+
* 5. Products derived from this software may not be called "Apache"
38+
* nor may "Apache" appear in their names without prior written
39+
* permission of the Apache Group.
40+
*
41+
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
42+
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
43+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
44+
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
45+
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
46+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
47+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
48+
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
49+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
50+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
51+
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
52+
* SUCH DAMAGE.
53+
* ====================================================================
54+
*
55+
* This software consists of voluntary contributions made by many
56+
* individuals on behalf of the Apache Software Foundation. For more
57+
* information on the Apache Software Foundation, please see
58+
* <http://www.apache.org/>.
59+
*
60+
*/
161
package org.apache.commons.cli;
262

363
/**
64+
* The class BasicParser provides a very simple implementation of
65+
* the {@link Parser#flatten(Options,String[],boolean) flatten} method.
66+
*
467
* @author John Keyes (jbjk at mac.com)
68+
* @see Parser
569
*/
670
public class BasicParser extends Parser {
771

72+
/**
73+
* <p>A simple implementation of {@link Parser}'s abstract
74+
* {@link Parser#flatten(Options,String[],boolean) flatten} method.</p>
75+
*
76+
* <p><b>Note:</b> <code>options</code> and <code>stopAtNonOption</code>
77+
* are not used in this <code>flatten</code> method.</p>
78+
*
79+
* @param options The command line {@link Options}
80+
* @param arguments The command line arguments to be parsed
81+
* @param stopAtNonOption Specifies whether to stop flattening
82+
* when an non option is found.
83+
* @return The <code>arguments</code> String array.
84+
*/
885
protected String[] flatten( Options options,
986
String[] arguments,
1087
boolean stopAtNonOption )
1188
{
89+
// just echo the arguments
1290
return arguments;
1391
}
1492
}

src/java/org/apache/commons/cli/CommandLine.java

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
* <http://www.apache.org/>.
5959
*
6060
*/
61-
6261
package org.apache.commons.cli;
6362

6463
import java.util.Collection;
@@ -68,7 +67,8 @@
6867
import java.util.LinkedList;
6968
import java.util.Map;
7069

71-
/** <p>Represents list of arguments parsed against
70+
/**
71+
* <p>Represents list of arguments parsed against
7272
* a {@link Options} descriptor.<p>
7373
*
7474
* <p>It allows querying of a boolean {@link #hasOption(String opt)},
@@ -81,8 +81,6 @@
8181
* @author bob mcwhirter (bob @ werken.com)
8282
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
8383
* @author John Keyes (jbjk at mac.com)
84-
*
85-
* @version $Revision: 1.4 $
8684
*/
8785
public class CommandLine {
8886

@@ -104,7 +102,8 @@ public class CommandLine {
104102
CommandLine() {
105103
}
106104

107-
/** <p>Query to see if an option has been set.</p>
105+
/**
106+
* <p>Query to see if an option has been set.</p>
108107
*
109108
* @param opt Short name of the option
110109
* @return true if set, false if not
@@ -113,7 +112,8 @@ public boolean hasOption(String opt) {
113112
return options.containsKey( opt );
114113
}
115114

116-
/** <p>Query to see if an option has been set.</p>
115+
/**
116+
* <p>Query to see if an option has been set.</p>
117117
*
118118
* @param opt character name of the option
119119
* @return true if set, false if not
@@ -123,8 +123,10 @@ public boolean hasOption( char opt ) {
123123
}
124124

125125
/**
126+
* <p>Return the <code>Object</code> type of this <code>Option</code>.</p>
127+
*
126128
* @param opt the name of the option
127-
* @return the type of opt
129+
* @return the type of this <code>Option</code>
128130
*/
129131
public Object getOptionObject( String opt ) {
130132
String res = getOptionValue( opt );
@@ -134,36 +136,44 @@ public Object getOptionObject( String opt ) {
134136
}
135137

136138
/**
139+
* <p>Return the <code>Object</code> type of this <code>Option</code>.</p>
140+
*
137141
* @param opt the name of the option
138142
* @return the type of opt
139143
*/
140144
public Object getOptionObject( char opt ) {
141145
return getOptionObject( String.valueOf( opt ) );
142146
}
143147

144-
/** <p>Retrieve the argument, if any, of an option.</p>
148+
/**
149+
* <p>Retrieve the argument, if any, of this option.</p>
145150
*
146151
* @param opt the name of the option
147-
* @return Value of the argument if option is set, and has an argument, else null.
152+
* @return Value of the argument if option is set, and has an argument,
153+
* otherwise null.
148154
*/
149155
public String getOptionValue( String opt ) {
150156
String[] values = getOptionValues(opt);
151157
return (values == null) ? null : values[0];
152158
}
153159

154-
/** <p>Retrieve the argument, if any, of an option.</p>
160+
/**
161+
* <p>Retrieve the argument, if any, of this option.</p>
155162
*
156163
* @param opt the character name of the option
157-
* @return Value of the argument if option is set, and has an argument, else null.
164+
* @return Value of the argument if option is set, and has an argument,
165+
* otherwise null.
158166
*/
159167
public String getOptionValue( char opt ) {
160168
return getOptionValue( String.valueOf( opt ) );
161169
}
162170

163-
/** <p>Retrieves the array of values, if any, of an option.</p>
171+
/**
172+
* <p>Retrieves the array of values, if any, of an option.</p>
164173
*
165174
* @param opt string name of the option
166-
* @return An array of values if the option is set, and has an argument, else null.
175+
* @return Values of the argument if option is set, and has an argument,
176+
* otherwise null.
167177
*/
168178
public String[] getOptionValues( String opt ) {
169179
List values = new java.util.ArrayList();
@@ -180,49 +190,57 @@ public String[] getOptionValues( String opt ) {
180190
return (values.size() == 0) ? null : (String[])values.toArray(new String[]{});
181191
}
182192

183-
/** <p>Retrieves the array of values, if any, of an option.</p>
193+
/**
194+
* <p>Retrieves the array of values, if any, of an option.</p>
184195
*
185196
* @param opt character name of the option
186-
* @return An array of values if the option is set, and has an argument, else null.
197+
* @return Values of the argument if option is set, and has an argument,
198+
* otherwise null.
187199
*/
188200
public String[] getOptionValues( char opt ) {
189201
return getOptionValues( String.valueOf( opt ) );
190202
}
191203

192-
/** <p>Retrieve the argument, if any, of an option.</p>
204+
/**
205+
* <p>Retrieve the argument, if any, of an option.</p>
193206
*
194207
* @param opt name of the option
195208
* @param defaultValue is the default value to be returned if the option is not specified
196-
* @return Value of the argument if option is set, and has an argument, else null.
209+
* @return Value of the argument if option is set, and has an argument,
210+
* otherwise <code>defaultValue</code>.
197211
*/
198212
public String getOptionValue( String opt, String defaultValue ) {
199213
String answer = getOptionValue( opt );
200214
return ( answer != null ) ? answer : defaultValue;
201215
}
202216

203-
/** <p>Retrieve the argument, if any, of an option.</p>
217+
/**
218+
* <p>Retrieve the argument, if any, of an option.</p>
204219
*
205220
* @param opt character name of the option
206221
* @param defaultValue is the default value to be returned if the option is not specified
207-
* @return Value of the argument if option is set, and has an argument, else null.
222+
* @return Value of the argument if option is set, and has an argument,
223+
* otherwise <code>defaultValue</code>.
208224
*/
209225
public String getOptionValue( char opt, String defaultValue ) {
210226
return getOptionValue( String.valueOf( opt ), defaultValue );
211227
}
212228

213-
/** <p>Retrieve any left-over non-recognized options and arguments</p>
229+
/**
230+
* <p>Retrieve any left-over non-recognized options and arguments</p>
214231
*
215-
* @return an array of remaining items passed in but not parsed
232+
* @return remaining items passed in but not parsed as an array
216233
*/
217234
public String[] getArgs() {
218235
String[] answer = new String[ args.size() ];
219236
args.toArray( answer );
220237
return answer;
221238
}
222239

223-
/** <p>Retrieve any left-over non-recognized options and arguments</p>
240+
/**
241+
* <p>Retrieve any left-over non-recognized options and arguments</p>
224242
*
225-
* @return List of remaining items passed in but not parsed
243+
* @return remaining items passed in but not parsed as a <code>List</code>.
226244
*/
227245
public List getArgList() {
228246
return args;

src/java/org/apache/commons/cli/CommandLineParser.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
2-
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//cli/src/java/org/apache/commons/cli/CommandLineParser.java,v 1.2 2002/07/04 22:32:12 jkeyes Exp $
3-
* $Revision: 1.2 $
4-
* $Date: 2002/07/04 22:32:12 $
2+
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//cli/src/java/org/apache/commons/cli/CommandLineParser.java,v 1.3 2002/08/26 20:15:02 jkeyes Exp $
3+
* $Revision: 1.3 $
4+
* $Date: 2002/08/26 20:15:02 $
55
*
66
* ====================================================================
77
*
@@ -61,6 +61,10 @@
6161
package org.apache.commons.cli;
6262

6363
/**
64+
* A class that implements the <code>CommandLineParser</code> interface
65+
* can parse a String array according to the {@link Options} specified
66+
* and return a {@link CommandLine}.
67+
*
6468
* @author John Keyes (jbjk at mac.com)
6569
*/
6670
public interface CommandLineParser {

src/java/org/apache/commons/cli/CommandLineParserFactory.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
2-
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//cli/src/java/org/apache/commons/cli/Attic/CommandLineParserFactory.java,v 1.3 2002/08/24 22:15:31 jkeyes Exp $
3-
* $Revision: 1.3 $
4-
* $Date: 2002/08/24 22:15:31 $
2+
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//cli/src/java/org/apache/commons/cli/Attic/CommandLineParserFactory.java,v 1.4 2002/08/26 20:15:02 jkeyes Exp $
3+
* $Revision: 1.4 $
4+
* $Date: 2002/08/26 20:15:02 $
55
*
66
* ====================================================================
77
*
@@ -73,13 +73,15 @@ public class CommandLineParserFactory {
7373
private static String DEFAULT_PARSER = "org.apache.commons.cli.PosixParser";
7474

7575
/**
76-
* @return the CommandLineParser
76+
* @return the default CommandLineParser
7777
*/
7878
public static CommandLineParser newParser() {
7979
return newParser( DEFAULT_PARSER );
8080
}
8181

8282
/**
83+
* @param classname the name of the parser class
84+
*
8385
* @return the CommandLineParser specified by <code>classname</code>.
8486
*/
8587
public static CommandLineParser newParser( String classname ) {

0 commit comments

Comments
 (0)