Java Reference
In-Depth Information
/** Construct a GetOpt parser, storing the set of option characters.
* This is a legacy constructor for backward compatibility.
* That said, it is easier to use if you don't need long-name options,
* so it has not been and will not be marked "deprecated".
*/
public
public GetOpt ( final
final String patt ) {
iif ( patt == null
null ) {
throw
throw new
new IllegalArgumentException ( "Pattern may not be null" );
}
iif ( patt . charAt ( 0 ) == ':' ) {
throw
throw new
new IllegalArgumentException (
"Pattern incorrect, may not begin with ':'" );
}
// Pass One: just count the option letters in the pattern
int
int n = 0 ;
for
for ( char
char ch : patt . toCharArray ()) {
iif ( ch != ':' )
++ n ;
}
iif ( n == 0 ) {
throw
throw new
new IllegalArgumentException (
"No option letters found in " + patt );
}
// Pass Two: construct an array of GetOptDesc objects.
options = new
new GetOptDesc [ n ];
for
for ( int
int i = 0 , ix = 0 ; i < patt . length (); i ++) {
final
char c = patt . charAt ( i );
boolean
final char
false ;
iif ( i < patt . length () - 1 && patt . charAt ( i + 1 ) == ':' ) {
argTakesValue = true
boolean argTakesValue = false
true ;
++ i ;
}
Debug . println ( "getopt" ,
"CONSTR: options[" + ix + "] = " + c + ", " + argTakesValue );
options [ ix ++] = new
new GetOptDesc ( c , null
null , argTakesValue );
}
}
/** Reset this GetOpt parser */
public
public void
void rewind () {
fileNameArguments = null
null ;
done = false
false ;
optind = 0 ;
Search WWH ::




Custom Search