1
1
/*
2
- * Copyright 2002-2011 the original author or authors.
2
+ * Copyright 2002-2013 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
52
52
class SimpleCommandLineArgsParser {
53
53
54
54
/**
55
- * Parse the given {@code String} array based on the rules described {@linkplain
56
- * SimpleCommandLineArgsParser above}, returning a fully-populated
57
- * {@link CommandLineArgs} object.
55
+ * Parse the given {@code String} array based on the rules described
56
+ * {@linkplain SimpleCommandLineArgsParser above}, returning a
57
+ * fully-populated {@link CommandLineArgs} object.
58
58
* @param args command line arguments, typically from a {@code main()} method
59
59
*/
60
60
public CommandLineArgs parse (String ... args ) {
@@ -65,13 +65,13 @@ public CommandLineArgs parse(String... args) {
65
65
String optionName ;
66
66
String optionValue = null ;
67
67
if (optionText .contains ("=" )) {
68
- optionName = optionText .substring (0 , optionText .indexOf ("=" ));
69
- optionValue = optionText .substring (optionText .indexOf ("=" )+ 1 , optionText .length ());
68
+ optionName = optionText .substring (0 , optionText .indexOf ('=' ));
69
+ optionValue = optionText .substring (optionText .indexOf ('=' ) + 1 , optionText .length ());
70
70
}
71
71
else {
72
72
optionName = optionText ;
73
73
}
74
- if (optionName .isEmpty () || (optionValue != null && optionValue .isEmpty () )) {
74
+ if (optionName .length () == 0 || (optionValue != null && optionValue .length () == 0 )) {
75
75
throw new IllegalArgumentException ("Invalid argument syntax: " + arg );
76
76
}
77
77
commandLineArgs .addOptionArg (optionName , optionValue );
0 commit comments