FileDocCategorySizeDatePackage
Parser.javaAPI DocApache Axis 1.415312Sat Apr 22 18:57:26 BST 2006org.apache.axis.wsdl.gen

Parser

public class Parser extends Object
This is a class with no documentation.

Fields Summary
protected boolean
debug
Field debug
protected boolean
quiet
Field quiet
protected boolean
imports
Field imports
protected boolean
verbose
Field verbose
protected boolean
nowrap
Field nowrap
protected String
username
Field username
protected String
password
Field password
protected boolean
wrapArrays
If this is false, we'll prefer "String[]" to "ArrayOfString" for literal wrapped arrays
private long
timeoutms
Field timeoutms
private GeneratorFactory
genFactory
Field genFactory
private org.apache.axis.wsdl.symbolTable.SymbolTable
symbolTable
Field symbolTable
Constructors Summary
Methods Summary
private voidgenerate(org.apache.axis.wsdl.symbolTable.SymbolTable symbolTable)
Method generate

param
symbolTable
throws
IOException


        sanityCheck(symbolTable);

        Definition def = symbolTable.getDefinition();

        genFactory.generatorPass(def, symbolTable);

        if (isDebug()) {
            symbolTable.dump(System.out);
        }

        // Generate bindings for types
        generateTypes(symbolTable);

        Iterator it = symbolTable.getHashMap().values().iterator();

        while (it.hasNext()) {
            Vector v = (Vector) it.next();

            for (int i = 0; i < v.size(); ++i) {
                SymTabEntry entry = (SymTabEntry) v.elementAt(i);
                Generator gen = null;

                if (entry instanceof MessageEntry) {
                    gen = genFactory.getGenerator(
                            ((MessageEntry) entry).getMessage(), symbolTable);
                } else if (entry instanceof PortTypeEntry) {
                    PortTypeEntry pEntry = (PortTypeEntry) entry;

                    // If the portType is undefined, then we're parsing a Definition
                    // that didn't contain a portType, merely a binding that referred
                    // to a non-existent port type.  Don't bother writing it.
                    if (pEntry.getPortType().isUndefined()) {
                        continue;
                    }

                    gen = genFactory.getGenerator(pEntry.getPortType(),
                            symbolTable);
                } else if (entry instanceof BindingEntry) {
                    BindingEntry bEntry = (BindingEntry) entry;
                    Binding binding = bEntry.getBinding();

                    // If the binding is undefined, then we're parsing a Definition
                    // that didn't contain a binding, merely a service that referred
                    // to a non-existent binding.  Don't bother writing it.
                    if (binding.isUndefined() || !bEntry.isReferenced()) {
                        continue;
                    }

                    gen = genFactory.getGenerator(binding, symbolTable);
                } else if (entry instanceof ServiceEntry) {
                    gen = genFactory.getGenerator(
                            ((ServiceEntry) entry).getService(), symbolTable);
                }

                if (gen != null) {
                    gen.generate();
                }
            }
        }

        // Output extra stuff (deployment files and faults)
        // outside of the recursive emit method.
        Generator gen = genFactory.getGenerator(def, symbolTable);

        gen.generate();
    
private voidgenerateTypes(org.apache.axis.wsdl.symbolTable.SymbolTable symbolTable)
Generate bindings (classes and class holders) for the complex types. If generating serverside (skeleton) spit out beanmappings

param
symbolTable
throws
IOException


        Map elements = symbolTable.getElementIndex();
        Collection elementCollection = elements.values();
        for (Iterator i = elementCollection.iterator(); i.hasNext(); ) {
            TypeEntry type = (TypeEntry) i.next();

            // Write out the type if and only if:
            // - we found its definition (getNode())
            // - it is referenced
            // - it is not a base type or an attributeGroup or xs:group
            // - it is a Type (not an Element) or a CollectionElement
            // (Note that types that are arrays are passed to getGenerator
            // because they may require a Holder)
            // A CollectionElement is an array that might need a holder
            boolean isType = ((type instanceof Type)
                    || (type instanceof CollectionElement));

            if ((type.getNode() != null)
                    && !Utils.isXsNode(type.getNode(), "attributeGroup")
                    && !Utils.isXsNode(type.getNode(), "group")
                    && type.isReferenced() && isType
                    && (type.getBaseType() == null)) {
                Generator gen = genFactory.getGenerator(type, symbolTable);

                gen.generate();
            }
        }

        Map types = symbolTable.getTypeIndex();
        Collection typeCollection = types.values();
        for (Iterator i = typeCollection.iterator(); i.hasNext(); ) {
            TypeEntry type = (TypeEntry) i.next();

            // Write out the type if and only if:
            // - we found its definition (getNode())
            // - it is referenced
            // - it is not a base type or an attributeGroup or xs:group
            // - it is a Type (not an Element) or a CollectionElement
            // (Note that types that are arrays are passed to getGenerator
            // because they may require a Holder)
            // A CollectionElement is an array that might need a holder
            boolean isType = ((type instanceof Type)
                    || (type instanceof CollectionElement));

            if ((type.getNode() != null)
                    && !Utils.isXsNode(type.getNode(), "attributeGroup")
                    && !Utils.isXsNode(type.getNode(), "group")
                    && type.isReferenced() && isType
                    && (type.getBaseType() == null)) {
                Generator gen = genFactory.getGenerator(type, symbolTable);

                gen.generate();
            }
        }
    
public javax.wsdl.DefinitiongetCurrentDefinition()
Return the current definition. The current definition is null until run is called.

return


        return (symbolTable == null)
                ? null
                : symbolTable.getDefinition();
    
public GeneratorFactorygetFactory()
Method getFactory

return

        return genFactory;
    
public java.lang.StringgetPassword()
Method getPassword

return

        return password;
    
public org.apache.axis.wsdl.symbolTable.SymbolTablegetSymbolTable()
Get the symbol table. The symbol table is null until run is called.

return

        return symbolTable;
    
public longgetTimeout()
Return the current timeout setting

return

        return timeoutms;
    
public java.lang.StringgetUsername()
Method getUsername

return

        return username;
    
public java.lang.StringgetWSDLURI()
Get the current WSDL URI. The WSDL URI is null until run is called.

return


        return (symbolTable == null)
                ? null
                : symbolTable.getWSDLURI();
    
public booleanisDebug()
Method isDebug

return


            
       
        return debug;
    
public booleanisImports()
Method isImports

return

        return imports;
    
public booleanisNowrap()
Method isNowrap

return

        return nowrap;
    
public booleanisQuiet()
Method isQuiet

return

        return quiet;
    
public booleanisVerbose()
Method isVerbose

return

        return verbose;
    
public voidrun(java.lang.String wsdlURI)
Parse a WSDL at a given URL.

This method will time out after the number of milliseconds specified by our timeoutms member.

param
wsdlURI
throws
Exception


        if (getFactory() == null) {
            setFactory(new NoopFactory());
        }

        symbolTable = new SymbolTable(genFactory.getBaseTypeMapping(), imports,
                verbose, nowrap);
        symbolTable.setQuiet(quiet);
        symbolTable.setWrapArrays(wrapArrays);

        // We run the actual Emitter in a thread that we can kill
        WSDLRunnable runnable = new WSDLRunnable(symbolTable, wsdlURI);
        Thread wsdlThread = new Thread(runnable);

        wsdlThread.start();

        try {
            if (timeoutms > 0) {
                wsdlThread.join(timeoutms);
            } else {
                wsdlThread.join();
            }
        } catch (InterruptedException e) {
        }

        if (wsdlThread.isAlive()) {
            wsdlThread.interrupt();

            throw new IOException(Messages.getMessage("timedOut"));
        }

        if (runnable.getFailure() != null) {
            throw runnable.getFailure();
        }
    
public voidrun(java.lang.String context, org.w3c.dom.Document doc)
Call this method if your WSDL document has already been parsed as an XML DOM document.

param
context context This is directory context for the Document. If the Document were from file "/x/y/z.wsdl" then the context could be "/x/y" (even "/x/y/z.wsdl" would work). If context is null, then the context becomes the current directory.
param
doc doc This is the XML Document containing the WSDL.
throws
IOException
throws
SAXException
throws
WSDLException
throws
ParserConfigurationException


        if (getFactory() == null) {
            setFactory(new NoopFactory());
        }

        symbolTable = new SymbolTable(genFactory.getBaseTypeMapping(), imports,
                verbose, nowrap);

        symbolTable.populate(context, doc);
        generate(symbolTable);
    
protected voidsanityCheck(org.apache.axis.wsdl.symbolTable.SymbolTable symbolTable)
Method sanityCheck

param
symbolTable


        // do nothing.
    
public voidsetDebug(boolean debug)
Method setDebug

param
debug

        this.debug = debug;
    
public voidsetFactory(GeneratorFactory factory)
Method setFactory

param
factory

        this.genFactory = factory;
    
public voidsetImports(boolean imports)
Method setImports

param
imports

        this.imports = imports;
    
public voidsetNowrap(boolean nowrap)
Method setNowrap

param
nowrap

        this.nowrap = nowrap;
    
public voidsetPassword(java.lang.String password)
Method setPassword

param
password

        this.password = password;
    
public voidsetQuiet(boolean quiet)
Method setQuiet

param
quiet

        this.quiet = quiet;
    
public voidsetTimeout(long timeout)
Set the timeout, in milliseconds

param
timeout

        this.timeoutms = timeout;
    
public voidsetUsername(java.lang.String username)
Method setUsername

param
username

        this.username = username;
    
public voidsetVerbose(boolean verbose)
Method setVerbose

param
verbose

        this.verbose = verbose;