⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 javageneratorfactory.java

📁 Java有关XML编程需要用到axis 的源代码 把里面bin下的包导入相应的Java工程 进行使用
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                    collisionCandidates.add(v);                }            }        }        Iterator it = collisionCandidates.iterator();                while (it.hasNext()) {            Vector v = new Vector(                    (Vector) it.next());    // New vector we can temporarily add to it                      // Remove MessageEntries since they are not mapped            int index = 0;            while (index < v.size()) {                if (v.elementAt(index) instanceof MessageEntry) {                    // Need to resolve a Exception message.                    MessageEntry msgEntry = (MessageEntry) v.elementAt(index);                                        if (msgEntry.getDynamicVar(EXCEPTION_CLASS_NAME) == null) {                        v.removeElementAt(index);                    } else {                                                index++;                    }                } else {                    index++;                }            }            if (v.size() > 1) {                boolean resolve = true;                // Common Special Case:                // If a Type and Element have the same QName, and the Element                // references the Type, then they are the same class so                // don't bother mangling.                if (v.size() == 2 &&                    ((v.elementAt(0) instanceof Element &&                      v.elementAt(1) instanceof Type) ||                     (v.elementAt(1) instanceof Element &&                      v.elementAt(0) instanceof Type))) {                    Element e;                    if (v.elementAt(0) instanceof Element) {                        e = (Element) v.elementAt(0);                    } else {                        e = (Element) v.elementAt(1);                    }                    BooleanHolder forElement = new BooleanHolder();                    QName eType = Utils.getTypeQName(e.getNode(),                            forElement, false);                    if ((eType != null)                             && !forElement.value) {                        resolve = false;                    }                }                // Other Special Case:                // If the names are already different, no mangling is needed.                if (resolve) {                    resolve = false;           // Assume false                    String name = null;                    for (int i = 0; (i < v.size()) && !resolve; ++i) {                        SymTabEntry entry = (SymTabEntry) v.elementAt(i);                        if ((entry instanceof MessageEntry)                                || (entry instanceof BindingEntry)) {                                                        // Need to resolve a exception class name                                                        String exceptionClassName = (String) entry.getDynamicVar(EXCEPTION_CLASS_NAME);                            if (exceptionClassName != null) {                                                                if (name == null) {                                    name = exceptionClassName;                                } else if (name.equals(exceptionClassName)) {                                    resolve = true;                                }                            }                        } else if (name == null) {                            name = entry.getName();                        } else if (name.equals(entry.getName())) {                            resolve = true;    // Need to do resolution                        }                    }                }                // Full Mangle if resolution is necessary.                if (resolve) {                    boolean firstType = true;                    for (int i = 0; i < v.size(); ++i) {                        SymTabEntry entry = (SymTabEntry) v.elementAt(i);                        if (entry instanceof Element) {                            entry.setName(mangleName(entry.getName(), ELEMENT_SUFFIX));                            // If this global element was defined using                            // an anonymous type, then need to change the                            // java name of the anonymous type to match.                            QName anonQName =                                    new QName(entry.getQName().getNamespaceURI(),                                            SymbolTable.ANON_TOKEN                                    + entry.getQName().getLocalPart());                                                        TypeEntry anonType =                                    symbolTable.getType(anonQName);                            if (anonType != null) {                                anonType.setName(entry.getName());                                anonTypes.add(anonType);                            }                                                    } else if (entry instanceof TypeEntry) {                            // Search all other types for java names that match this one.                            // The sameJavaClass method returns true if the java names are                            // the same (ignores [] ).                            if (firstType) {                                firstType = false;                                Iterator types =                                        symbolTable.getTypeIndex().values().iterator();                                while (types.hasNext()) {                                    TypeEntry type = (TypeEntry) types.next();                                    if ((type != entry)                                            && (type.getBaseType() == null)                                            && sameJavaClass(entry.getName(),                                                    type.getName())) {                                        v.add(type);                                    }                                }                            }                            // If this is an anonymous type, it's name was resolved in                            // the previous if block.  Don't reresolve it.                            if (!anonTypes.contains(entry)) {                                // In case that other entry in name collision among                                 // PortTypeEntry, ServiceEntry and BindingEntry                                                                boolean needResolve = false;                                                                // check collision of TypeEntry with PortTypeEntry, ServiceEtnry and/or BindingEntry                                 for (int j = 0; j < v.size(); j++) {                                    SymTabEntry e = (SymTabEntry) v.elementAt(j);                                    if ((e instanceof PortTypeEntry                                             || e instanceof ServiceEntry                                            || e instanceof BindingEntry)) {                                        needResolve = true;                                        break;                                    }                                }                                                                if (!needResolve) {                                    continue;                                }                                                                                                                                // Appended Suffix for avoiding name collisions (JAX-RPC 1.1)                                Boolean isComplexTypeFault = (Boolean)entry.getDynamicVar(COMPLEX_TYPE_FAULT);                                if ((isComplexTypeFault != null) && isComplexTypeFault.booleanValue()) {                                    entry.setName(mangleName(entry.getName(), EXCEPTION_SUFFIX));                                }                                 else {                                    entry.setName(mangleName(entry.getName(), TYPE_SUFFIX));                                }                                                                // should update the class name of ElementEntry which references this type entry                                Map elementIndex = symbolTable.getElementIndex();                                List elements = new ArrayList(elementIndex.values());                                for (int j = 0; j < elementIndex.size(); j++) {                                    TypeEntry te = (TypeEntry) elements.get(j);                                    TypeEntry ref = te.getRefType();                                    if (ref != null && entry.getQName().equals(ref.getQName())) {                                        te.setName(entry.getName());                                    }                                }                                                                           // Need to resolve a complex-type exception message.                                if ((isComplexTypeFault != null) && isComplexTypeFault.booleanValue()) {                                    // SHOULD update the exception class name of a referencing message entry.                                    List messageEntries = symbolTable.getMessageEntries();                                    for (int j = 0; j < messageEntries.size(); j++) {                                        MessageEntry messageEntry = (MessageEntry)messageEntries.get(j);                                        Boolean isComplexTypeFaultMsg = (Boolean)messageEntry.getDynamicVar(COMPLEX_TYPE_FAULT);                                        if ((isComplexTypeFaultMsg != null) && (isComplexTypeFaultMsg.booleanValue())) {                                            QName exceptionDataType = (QName)messageEntry.getDynamicVar(EXCEPTION_DATA_TYPE);                                            if (((TypeEntry)entry).getQName().equals(exceptionDataType)) {                                                String className = (String)messageEntry.getDynamicVar(EXCEPTION_CLASS_NAME);                                                messageEntry.setDynamicVar(EXCEPTION_CLASS_NAME, className + EXCEPTION_SUFFIX);                                            }                                        }                                    }                                }                            }                        } else if (entry instanceof PortTypeEntry) {                            entry.setName(mangleName(entry.getName(), PORT_TYPE_SUFFIX));   // "_Port" --> "_PortType" for JAX-RPC 1.1                        } else if (entry instanceof ServiceEntry) {                            entry.setName(mangleName(entry.getName(), SERVICE_SUFFIX));                        } else if (entry instanceof MessageEntry) {                            Boolean complexTypeFault =                                 (Boolean) entry.getDynamicVar(COMPLEX_TYPE_FAULT);                            if ((complexTypeFault == null) || !complexTypeFault.booleanValue()) {                                String exceptionClassName = (String) entry.getDynamicVar(EXCEPTION_CLASS_NAME);                                entry.setDynamicVar(EXCEPTION_CLASS_NAME, exceptionClassName + EXCEPTION_SUFFIX);                            }                                                    }                        // else if (entry instanceof MessageEntry) {                        // we don't care about messages                        // }                        else if (entry instanceof BindingEntry) {                            BindingEntry bEntry = (BindingEntry) entry;                            // If there is no literal use, then we never see a                            // class named directly from the binding name.  They                            // all have suffixes:  Stub, Skeleton, Impl.                            // If there IS literal use, then the SDI will be                            // named after the binding name, so there is the                            // possibility of a name clash.                            if (bEntry.hasLiteral()) {                                entry.setName(mangleName(entry.getName(),                                        BINDING_SUFFIX));                            }                        }                    }                }            }        }    }                                          // resolveNameClashes    /**     * Change the indicated type name into a mangled form using the mangle string.     *     * @param name     * @param mangle     * @return     */    private String mangleName(String name, String mangle) {        int index = name.indexOf("[");        if (index >= 0) {            String pre = name.substring(0, index);            String post = name.substring(index);            return pre + mangle + post;        } else {            return name + mangle;        }    }    /**     * Returns true if same java class, ignore []     *     * @param one     * @param two     * @return     */    private boolean sameJavaClass(String one, String two) {        int index1 = one.indexOf("[");        int index2 = two.indexOf("[");        if (index1 > 0) {            one = one.substring(0, index1);        }        if (index2 > 0) {            two = two.substring(0, index2);        }        return one.equals(two);    }    /**     * The --all flag is set on the command line (or generateAll(true) is called     * on WSDL2Java). Set all symbols as referenced (except nonSOAP bindings     * which we don't know how to deal with).     */    protected void setAllReferencesToTrue() {        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);                if ((entry instanceof BindingEntry)                        && ((BindingEntry) entry).getBindingType()                        != BindingEntry.TYPE_SOAP) {                    entry.setIsReferenced(false);                } else {                    entry.setIsReferenced(true);                }            }        }    }    // setAllReferencesToTrue    /**     * If a binding's type is not TYPE_SOAP, then we don't use that binding     * or that binding's portType.     *     * @param symbolTable     */    protected void ignoreNonSOAPBindings(SymbolTable symbolTable) {        // Look at all uses of the portTypes.  If none of the portType's bindings are of type        // TYPE_SOAP, then turn off that portType's isReferenced flag.        Vector unusedPortTypes = new Vector();        Vector usedPortTypes = new Vector();        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);                if (entry instanceof BindingEntry) {                    BindingEntry bEntry = (BindingEntry) entry;                    Binding binding = bEntry.getBinding();                    PortType portType = binding.getPortType();                    PortTypeEntry ptEntry =                            symbolTable.getPortTypeEntry(portType.getQName());                    if (bEntry.getBindingType() == BindingEntry.TYPE_SOAP) {                        // If a binding is of type TYPE_SOAP, then mark its portType used                        // (ie., add it to the usedPortTypes list.  If the portType was                        // previously marked as unused, unmark it (in other words, remove it                        // from the unusedPortTypes list).                        usedPortTypes.add(ptEntry);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -