FileDocCategorySizeDatePackage
WSDL2.javaAPI DocApache Axis 1.410574Sat Apr 22 18:57:28 BST 2006org.apache.axis.wsdl.gen

WSDL2

public class WSDL2 extends Object
Class WSDL2
version
%I%, %G%

Fields Summary
protected static final int
DEBUG_OPT
Field DEBUG_OPT
protected static final int
HELP_OPT
Field HELP_OPT
protected static final int
NETWORK_TIMEOUT_OPT
Field NETWORK_TIMEOUT_OPT
protected static final int
NOIMPORTS_OPT
Field NOIMPORTS_OPT
protected static final int
VERBOSE_OPT
Field VERBOSE_OPT
protected static final int
NOWRAP_OPT
Field NOWRAP_OPT
protected static final int
QUIET_OPT
Filed quiet
protected org.apache.axis.utils.CLOptionDescriptor[]
options
Field options
protected String
wsdlURI
Field wsdlURI
protected Parser
parser
Field parser
Constructors Summary
protected WSDL2()
Constructor Used by extended classes to construct an instance of WSDL2


                    
      
        parser = createParser();
    
Methods Summary
protected voidaddOptions(org.apache.axis.utils.CLOptionDescriptor[] newOptions)
addOptions Add option descriptions to the tool.

param
newOptions CLOptionDescriptor[] the options


        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 voidcheckForAuthInfo(java.lang.String uri)
checkForAuthInfo set user and password information

param
uri


        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 ParsercreateParser()
createParser Used by extended classes to construct an instance of the Parser

return

        return new Parser();
    
protected ParsergetParser()
getParser get the Parser object

return

        return parser;
    
public static voidmain(java.lang.String[] args)
Main Run the tool with the specified command-line arguments

param
args String[] command-line arguments


        WSDL2 wsdl2 = new WSDL2();

        wsdl2.run(args);
    
protected voidparseOption(org.apache.axis.utils.CLOption option)
Parse an option

param
option CLOption is the 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 voidprintUsage()
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 voidremoveOption(java.lang.String name)
removeOption Remove an option description from the tool.

param
name the name of the CLOptionDescriptor to remove


        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 voidrun(java.lang.String[] args)
run checkes the command-line arguments and runs the tool.

param
args String[] command-line arguments.


        // 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 voidvalidateOptions()
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()));