📄 symboltable.java
字号:
/* * Copyright 2001-2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.axis.wsdl.symbolTable;import org.apache.axis.Constants;import org.apache.axis.constants.Style;import org.apache.axis.constants.Use;import org.apache.axis.utils.Messages;import org.apache.axis.utils.URLHashSet;import org.apache.axis.utils.XMLUtils;import org.w3c.dom.Document;import org.w3c.dom.NamedNodeMap;import org.w3c.dom.Node;import org.w3c.dom.NodeList;import org.xml.sax.SAXException;import javax.wsdl.Binding;import javax.wsdl.BindingFault;import javax.wsdl.BindingInput;import javax.wsdl.BindingOperation;import javax.wsdl.BindingOutput;import javax.wsdl.Definition;import javax.wsdl.Fault;import javax.wsdl.Import;import javax.wsdl.Input;import javax.wsdl.Message;import javax.wsdl.Operation;import javax.wsdl.Output;import javax.wsdl.Part;import javax.wsdl.Port;import javax.wsdl.PortType;import javax.wsdl.Service;import javax.wsdl.WSDLException;import javax.wsdl.extensions.ExtensibilityElement;import javax.wsdl.extensions.UnknownExtensibilityElement;import javax.wsdl.extensions.http.HTTPBinding;import javax.wsdl.extensions.mime.MIMEContent;import javax.wsdl.extensions.mime.MIMEMultipartRelated;import javax.wsdl.extensions.mime.MIMEPart;import javax.wsdl.extensions.soap.SOAPBinding;import javax.wsdl.extensions.soap.SOAPBody;import javax.wsdl.extensions.soap.SOAPFault;import javax.wsdl.extensions.soap.SOAPHeader;import javax.wsdl.extensions.soap.SOAPHeaderFault;import javax.wsdl.factory.WSDLFactory;import javax.wsdl.xml.WSDLReader;import javax.xml.namespace.QName;import javax.xml.parsers.ParserConfigurationException;import javax.xml.rpc.holders.BooleanHolder;import javax.xml.rpc.holders.IntHolder;import javax.xml.rpc.holders.QNameHolder;import java.io.File;import java.io.IOException;import java.net.MalformedURLException;import java.net.URL;import java.util.ArrayList;import java.util.Collection;import java.util.Collections;import java.util.HashMap;import java.util.HashSet;import java.util.Iterator;import java.util.List;import java.util.Map;import java.util.Set;import java.util.Vector;/** * This class represents a table of all of the top-level symbols from a set of WSDL Definitions and * DOM Documents: XML types; WSDL messages, portTypes, bindings, and services. * <p/> * This symbolTable contains entries of the form <key, value> where key is of type QName and value is * of type Vector. The Vector's elements are all of the objects that have the given QName. This is * necessary since names aren't unique among the WSDL types. message, portType, binding, service, * could all have the same QName and are differentiated merely by type. SymbolTable contains * type-specific getters to bypass the Vector layer: * public PortTypeEntry getPortTypeEntry(QName name), etc. */public class SymbolTable { // used to cache dervied types protected HashMap derivedTypes = new HashMap(); // Should the contents of imported files be added to the symbol table? /** Field addImports */ private boolean addImports; // The actual symbol table. This symbolTable contains entries of the form // <key, value> where key is of type QName and value is of type Vector. The // Vector's elements are all of the objects that have the given QName. This // is necessary since names aren't unique among the WSDL types. message, // portType, binding, service, could all have the same QName and are // differentiated merely by type. SymbolTable contains type-specific // getters to bypass the Vector layer: // public PortTypeEntry getPortTypeEntry(QName name), etc. /** Field symbolTable */ private HashMap symbolTable = new HashMap(); // a map of qnames -> Elements in the symbol table /** Field elementTypeEntries */ private final Map elementTypeEntries = new HashMap(); // an unmodifiable wrapper so that we can share the index with others, safely /** Field elementIndex */ private final Map elementIndex = Collections.unmodifiableMap(elementTypeEntries); // a map of qnames -> Types in the symbol table /** Field typeTypeEntries */ private final Map typeTypeEntries = new HashMap(); // an unmodifiable wrapper so that we can share the index with others, safely /** Field typeIndex */ private final Map typeIndex = Collections.unmodifiableMap(typeTypeEntries); /** * cache of nodes -> base types for complexTypes. The cache is * built on nodes because multiple TypeEntry objects may use the * same node. */ protected final Map node2ExtensionBase = new HashMap(); // allow friendly access /** Field verbose */ private boolean verbose; /** Field quiet */ protected boolean quiet; /** Field btm */ private BaseTypeMapping btm = null; // should we attempt to treat document/literal WSDL as "rpc-style" /** Field nowrap */ private boolean nowrap; // Did we encounter wraped mode WSDL /** Field wrapped */ private boolean wrapped = false; /** Field ANON_TOKEN */ public static final String ANON_TOKEN = ">"; /** Field def */ private Definition def = null; /** Field wsdlURI */ private String wsdlURI = null; /** If this is false, we will "unwrap" literal arrays, generating a plan "String[]" instead * of "ArrayOfString" when encountering an element containing a single maxOccurs="unbounded" * inner element. */ private boolean wrapArrays; Set arrayTypeQNames = new HashSet(); /** Field elementFormDefaults */ private final Map elementFormDefaults = new HashMap(); /** * Construct a symbol table with the given Namespaces. * * @param btm * @param addImports * @param verbose * @param nowrap */ public SymbolTable(BaseTypeMapping btm, boolean addImports, boolean verbose, boolean nowrap) { this.btm = btm; this.addImports = addImports; this.verbose = verbose; this.nowrap = nowrap; } // ctor /** * Method isQuiet * * @return */ public boolean isQuiet() { return quiet; } /** * Method setQuiet * * @param quiet */ public void setQuiet(boolean quiet) { this.quiet = quiet; } /** * Get the raw symbol table HashMap. * * @return */ public HashMap getHashMap() { return symbolTable; } // getHashMap /** * Get the list of entries with the given QName. Since symbols can share QNames, this list is * necessary. This list will not contain any more than one element of any given SymTabEntry. * * @param qname * @return */ public Vector getSymbols(QName qname) { return (Vector) symbolTable.get(qname); } // get /** * Get the entry with the given QName of the given class. If it does not exist, return null. * * @param qname * @param cls * @return */ public SymTabEntry get(QName qname, Class cls) { Vector v = (Vector) symbolTable.get(qname); if (v == null) { return null; } else { for (int i = 0; i < v.size(); ++i) { SymTabEntry entry = (SymTabEntry) v.elementAt(i); if (cls.isInstance(entry)) { return entry; } } return null; } } // get /** * Get the type entry for the given qname. * * @param qname * @param wantElementType boolean that indicates type or element (for type= or ref=) * @return */ public TypeEntry getTypeEntry(QName qname, boolean wantElementType) { if (wantElementType) { return getElement(qname); } else { return getType(qname); } } // getTypeEntry /** * Get the Type TypeEntry with the given QName. If it doesn't * exist, return null. * * @param qname * @return */ public Type getType(QName qname) { return (Type) typeTypeEntries.get(qname); } // getType /** * Get the Element TypeEntry with the given QName. If it doesn't * exist, return null. * * @param qname * @return */ public Element getElement(QName qname) { return (Element) elementTypeEntries.get(qname); } // getElement /** * Get the MessageEntry with the given QName. If it doesn't exist, return null. * * @param qname * @return */ public MessageEntry getMessageEntry(QName qname) { return (MessageEntry) get(qname, MessageEntry.class); } // getMessageEntry /** * Get the PortTypeEntry with the given QName. If it doesn't exist, return null. * * @param qname * @return */ public PortTypeEntry getPortTypeEntry(QName qname) { return (PortTypeEntry) get(qname, PortTypeEntry.class); } // getPortTypeEntry /** * Get the BindingEntry with the given QName. If it doesn't exist, return null. * * @param qname * @return */ public BindingEntry getBindingEntry(QName qname) { return (BindingEntry) get(qname, BindingEntry.class); } // getBindingEntry /** * Get the ServiceEntry with the given QName. If it doesn't exist, return null. * * @param qname * @return */ public ServiceEntry getServiceEntry(QName qname) { return (ServiceEntry) get(qname, ServiceEntry.class); } // getServiceEntry /** * Get the list of all the XML schema types in the symbol table. In other words, all entries * that are instances of TypeEntry. * * @return * @deprecated use specialized get{Element,Type}Index() methods instead */ public Vector getTypes() { Vector v = new Vector(); v.addAll(elementTypeEntries.values()); v.addAll(typeTypeEntries.values()); return v; } // getTypes /** * Return an unmodifiable map of qnames -> Elements in the symbol * table. * * @return an unmodifiable <code>Map</code> value */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -