Fields Summary |
---|
protected static final int | DEBUG_OPTField DEBUG_OPT |
protected static final int | HELP_OPTField HELP_OPT |
protected static final int | NETWORK_TIMEOUT_OPTField NETWORK_TIMEOUT_OPT |
protected static final int | NOIMPORTS_OPTField NOIMPORTS_OPT |
protected static final int | VERBOSE_OPTField VERBOSE_OPT |
protected static final int | NOWRAP_OPTField NOWRAP_OPT |
protected static final int | QUIET_OPTFiled quiet |
protected org.apache.axis.utils.CLOptionDescriptor[] | optionsField options |
protected String | wsdlURIField wsdlURI |
protected Parser | parserField parser |
Methods Summary |
---|
protected void | addOptions(org.apache.axis.utils.CLOptionDescriptor[] newOptions)addOptions
Add option descriptions to the tool.
if ((newOptions != null) && (newOptions.length > 0)) {
CLOptionDescriptor[] allOptions =
new CLOptionDescriptor[options.length + newOptions.length];
System.arraycopy(options, 0, allOptions, 0, options.length);
System.arraycopy(newOptions, 0, allOptions, options.length,
newOptions.length);
options = allOptions;
}
|
private void | checkForAuthInfo(java.lang.String uri)checkForAuthInfo
set user and password information
URL url = null;
try {
url = new URL(uri);
} catch (MalformedURLException e) {
// not going to have userInfo
return;
}
String userInfo = url.getUserInfo();
if (userInfo != null) {
int i = userInfo.indexOf(':");
if (i >= 0) {
parser.setUsername(userInfo.substring(0, i));
parser.setPassword(userInfo.substring(i + 1));
} else {
parser.setUsername(userInfo);
}
}
|
protected Parser | createParser()createParser
Used by extended classes to construct an instance of the Parser
return new Parser();
|
protected Parser | getParser()getParser
get the Parser object
return parser;
|
public static void | main(java.lang.String[] args)Main
Run the tool with the specified command-line arguments
WSDL2 wsdl2 = new WSDL2();
wsdl2.run(args);
|
protected void | parseOption(org.apache.axis.utils.CLOption option)Parse an option
switch (option.getId()) {
case CLOption.TEXT_ARGUMENT:
if (wsdlURI != null) {
System.out.println(
Messages.getMessage(
"w2jDuplicateWSDLURI00", wsdlURI,
option.getArgument()));
printUsage();
}
wsdlURI = option.getArgument();
break;
case HELP_OPT:
printUsage();
break;
case NOIMPORTS_OPT:
parser.setImports(false);
break;
case NETWORK_TIMEOUT_OPT:
String timeoutValue = option.getArgument();
long timeout = Long.parseLong(timeoutValue);
// Convert seconds to milliseconds.
if (timeout > 0) {
timeout = timeout * 1000;
}
parser.setTimeout(timeout);
break;
case VERBOSE_OPT:
parser.setVerbose(true);
break;
case DEBUG_OPT:
parser.setDebug(true);
break;
case QUIET_OPT:
parser.setQuiet(true);
break;
case NOWRAP_OPT:
parser.setNowrap(true);
break;
}
|
protected void | printUsage()printUsage
print usage information and quit.
String lSep = System.getProperty("line.separator");
StringBuffer msg = new StringBuffer();
msg.append(Messages.getMessage("usage00",
"java " + getClass().getName()
+ " [options] WSDL-URI")).append(lSep);
msg.append(Messages.getMessage("options00")).append(lSep);
msg.append(CLUtil.describeOptions(options).toString());
System.out.println(msg.toString());
System.exit(1);
|
protected void | removeOption(java.lang.String name)removeOption
Remove an option description from the tool.
int foundOptionIndex = -1;
for (int i = 0; i < options.length; i++) {
if (options[i].getName().equals(name)) {
foundOptionIndex = i;
break;
}
}
if (foundOptionIndex != -1) {
CLOptionDescriptor[] newOptions =
new CLOptionDescriptor[options.length - 1];
System.arraycopy(options, 0, newOptions, 0, foundOptionIndex);
if (foundOptionIndex < newOptions.length) {
System.arraycopy(options, foundOptionIndex + 1, newOptions,
foundOptionIndex,
newOptions.length - foundOptionIndex);
}
options = newOptions;
}
|
protected void | run(java.lang.String[] args)run
checkes the command-line arguments and runs the tool.
// Parse the arguments
CLArgsParser argsParser = new CLArgsParser(args, options);
// Print parser errors, if any
if (null != argsParser.getErrorString()) {
System.err.println(
Messages.getMessage("error01", argsParser.getErrorString()));
printUsage();
}
// Get a list of parsed options
List clOptions = argsParser.getArguments();
int size = clOptions.size();
try {
// Parse the options and configure the emitter as appropriate.
for (int i = 0; i < size; i++) {
parseOption((CLOption) clOptions.get(i));
}
// validate argument combinations
//
validateOptions();
parser.run(wsdlURI);
// everything is good
System.exit(0);
} catch (Throwable t) {
t.printStackTrace();
System.exit(1);
}
|
protected void | validateOptions()validateOptions
This method is invoked after the options are set to validate and default the options
the option settings.
if (wsdlURI == null) {
System.out.println(Messages.getMessage("w2jMissingWSDLURI00"));
printUsage();
}
if (parser.isQuiet()) {
if (parser.isVerbose()) {
System.out.println(Messages.getMessage("exclusiveQuietVerbose"));
printUsage();
}
if (parser.isDebug()) {
System.out.println(Messages.getMessage("exclusiveQuietDebug"));
printUsage();
}
}
// Set username and password if provided in URL
checkForAuthInfo(wsdlURI);
Authenticator.setDefault(new DefaultAuthenticator(parser.getUsername(),
parser.getPassword()));
|