/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* See LICENSE.txt included in this distribution for the specific
* language governing permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at LICENSE.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/**
* A simple implementation of the getopt(3c). It does just implement what I
* need ;-) Please note that I dislike the way GNU getopt allows mixing of
* options and arguments, so this version will stop processing options as soon
* as it encounters an argument.
*
*/
public class Getopt {
private static class Option {
char option;
}
private int current;
private int optind;
/**
* Creates a new instance of Getopt
* @param argv argument vector
* @param opts the list of allowed options
*/
current = -1;
optind = -1;
}
/**
* Parse the command line options
* @throws ParseException if an illegal argument is passed
*/
int ii = 0;
// End of command line options ;)
break;
}
if (idx == -1) {
}
// does this option take an argument?
// next should be an argument
// Rest of this is the argument
break;
}
// next argument vector contains the argument
++ii;
} else {
}
}
}
++ii;
} else {
// End of options
break;
}
}
}
/**
* Get the next option in the options string.
* @return the next valid option, or -1 if all options are processed
*/
public int getOpt() {
int ret = -1;
++current;
}
return ret;
}
/**
* Reset the current pointer so we may traverse all the options again..
*/
public void reset() {
current = -1;
}
/**
* Get the argument to the current option
* @return the argument or null if none present (or allowed)
*/
}
return ret;
}
/**
* Get the index of the first argument
* @return the index of the first argument in the original array
*/
public int getOptind() {
return optind;
}
}