23
23
24
24
package nsk .share .jvmti ;
25
25
26
- import nsk .share .*;
26
+ import nsk .share .ArgumentParser ;
27
+ import nsk .share .Failure ;
27
28
28
- import java .io .*;
29
- import java .util .*;
29
+ import java .util .StringTokenizer ;
30
30
31
31
/**
32
32
* Parser for JVMTI test's specific command-line arguments.
37
37
* form agent option string. These options are added to the options list
38
38
* and can be found using <i>FindOption*Value()</i> methods.
39
39
* <p>
40
- * Currently no specific options are recognized by <code>AgrumentHandler </code>.
40
+ * Currently no specific options are recognized by <code>ArgumentHandler </code>.
41
41
* <p>
42
42
* See description of <code>ArgumentParser</code> to know which general options
43
43
* are recognized and how to get them.
44
44
*
45
45
* @see ArgumentParser
46
- *
47
46
* @see #findOptionValue(String)
48
- * @see #findOptionStringValue(String,String)
49
- * @see #findOptionIntValue(String,int)
47
+ * @see #findOptionIntValue(String, int)
50
48
*/
51
49
public class ArgumentHandler extends ArgumentParser {
52
50
@@ -55,15 +53,13 @@ public class ArgumentHandler extends ArgumentParser {
55
53
* but throw an exception on parsing error; and also add options
56
54
* obtained from agent options string.
57
55
*
58
- * @param args Array of the raw command-line arguments.
59
- *
60
- * @throws NullPointerException If <code>args==null</code>.
61
- * @throws IllegalArgumentException If Binder or Log options
62
- * are set incorrectly.
63
- *
56
+ * @param args Array of the raw command-line arguments.
57
+ * @throws NullPointerException If <code>args==null</code>.
58
+ * @throws IllegalArgumentException If Binder or Log options
59
+ * are set incorrectly.
64
60
* @see #setRawArguments(String[])
65
61
*/
66
- public ArgumentHandler (String args [] ) {
62
+ public ArgumentHandler (String [] args ) {
67
63
super (args );
68
64
String agentOptions = getAgentOptionsString ();
69
65
if (agentOptions == null ) {
@@ -76,25 +72,7 @@ public ArgumentHandler(String args[]) {
76
72
* Return value of given option if specified; or <i>null</i> otherwise.
77
73
*/
78
74
public String findOptionValue (String name ) {
79
- String value = options .getProperty (name );
80
- return value ;
81
- }
82
-
83
- /**
84
- * Return string value of given option if specified; or <i>defaultValue</i> otherwise.
85
- *
86
- * @throws BadOption if option is specified but has empty value.
87
- */
88
- public String findOptionStringValue (String name , String defaultValue ) {
89
- String value = options .getProperty (name );
90
- if (value == null ) {
91
- return defaultValue ;
92
- }
93
-
94
- if (value .length () <= 0 ) {
95
- throw new BadOption ("Empty value of option: " + name + "=" + value );
96
- }
97
- return value ;
75
+ return options .getProperty (name );
98
76
}
99
77
100
78
/**
@@ -120,13 +98,11 @@ public int findOptionIntValue(String name, int defaultValue) {
120
98
* This method is invoked by <code>parseArguments()</code>.
121
99
*
122
100
* @param option option name
123
- * @param value string representation of value (could be an empty string);
124
- * or null if this option has no value
101
+ * @param value string representation of value (could be an empty string);
102
+ * or null if this option has no value
125
103
* @return <i>true</i> if option is admissible and has proper value;
126
- * <i>false</i> if otion is not admissible
127
- *
128
- * @throws <i>BadOption</i> if admissible option has illegal value
129
- *
104
+ * <i>false</i> if option is not admissible
105
+ * @throws BadOption if admissible option has illegal value
130
106
* @see #parseArguments()
131
107
*/
132
108
protected boolean checkOption (String option , String value ) {
@@ -147,8 +123,8 @@ protected void checkOptions() {
147
123
* Parse options string and add all recognized options and their values.
148
124
* If optionString is <i>null</i> this method just does nothing.
149
125
*
150
- * @throws BadOption if known option has illegel value
151
- * or all options are inconsistent
126
+ * @throws BadOption if known option has illegal value
127
+ * or all options are inconsistent
152
128
*/
153
129
protected void parseOptionString (String optionString ) {
154
130
if (optionString == null )
@@ -157,7 +133,7 @@ protected void parseOptionString(String optionString) {
157
133
StringTokenizer st = new StringTokenizer (optionString , " ,~" );
158
134
while (st .hasMoreTokens ()) {
159
135
String token = st .nextToken ();
160
- int start = token .startsWith ("-" )? 1 : 0 ;
136
+ int start = token .startsWith ("-" ) ? 1 : 0 ;
161
137
String name , value ;
162
138
int k = token .indexOf ('=' );
163
139
if (k < 0 ) {
0 commit comments