📄 schemautils.java
字号:
} return null; } /** * If the specified node represents an array encoding of one of the following * forms, then return the qname repesenting the element type of the array. * * @param node is the node * @param dims is the output value that contains the number of dimensions if return is not null * @return QName or null * <p/> * JAX-RPC Style 2: * <xsd:complexType name="hobbyArray"> * <xsd:complexContent> * <xsd:restriction base="soapenc:Array"> * <xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]"/> * </xsd:restriction> * </xsd:complexContent> * </xsd:complexType> * <p/> * JAX-RPC Style 3: * <xsd:complexType name="petArray"> * <xsd:complexContent> * <xsd:restriction base="soapenc:Array"> * <xsd:sequence> * <xsd:element name="alias" type="xsd:string" maxOccurs="unbounded"/> * </xsd:sequence> * </xsd:restriction> * </xsd:complexContent> * </xsd:complexType> */ private static QName getArrayComponentQName_JAXRPC(Node node, IntHolder dims, BooleanHolder underlTypeNillable, SymbolTable symbolTable) { dims.value = 0; // Assume 0 underlTypeNillable.value = false; if (node == null) { return null; } // If the node kind is an element, dive into it. if (isXSDNode(node, "element")) { NodeList children = node.getChildNodes(); for (int j = 0; j < children.getLength(); j++) { Node kid = children.item(j); if (isXSDNode(kid, "complexType")) { node = kid; break; } } } // Get the node kind, expecting a schema complexType if (isXSDNode(node, "complexType")) { // Under the complexType there should be a complexContent. // (There may be other #text nodes, which we will ignore). NodeList children = node.getChildNodes(); Node complexContentNode = null; for (int j = 0; j < children.getLength(); j++) { Node kid = children.item(j); if (isXSDNode(kid, "complexContent") || isXSDNode(kid, "simpleContent")) { complexContentNode = kid; break; } } // Under the complexContent there should be a restriction. // (There may be other #text nodes, which we will ignore). Node restrictionNode = null; if (complexContentNode != null) { children = complexContentNode.getChildNodes(); for (int j = 0; j < children.getLength(); j++) { Node kid = children.item(j); if (isXSDNode(kid, "restriction")) { restrictionNode = kid; break; } } } // The restriction node must have a base of soapenc:Array. QName baseType = null; if (restrictionNode != null) { baseType = Utils.getTypeQName(restrictionNode, new BooleanHolder(), false); if (baseType != null) { if (!baseType.getLocalPart().equals("Array") || !Constants.isSOAP_ENC(baseType.getNamespaceURI())) { if (!symbolTable.arrayTypeQNames.contains(baseType)) { baseType = null; // Did not find base=soapenc:Array } } } } // Under the restriction there should be an attribute OR a sequence/all group node. // (There may be other #text nodes, which we will ignore). Node groupNode = null; Node attributeNode = null; if (baseType != null) { children = restrictionNode.getChildNodes(); for (int j = 0; (j < children.getLength()) && (groupNode == null) && (attributeNode == null); j++) { Node kid = children.item(j); if (isXSDNode(kid, "sequence") || isXSDNode(kid, "all")) { groupNode = kid; if (groupNode.getChildNodes().getLength() == 0) { // This covers the rather odd but legal empty sequence. // <complexType name="ArrayOfString"> // <complexContent> // <restriction base="soapenc:Array"> // <sequence/> // <attribute ref="soapenc:arrayType" wsdl:arrayType="string[]"/> // </restriction> // </complexContent> // </complexType> groupNode = null; } } if (isXSDNode(kid, "attribute")) { // If the attribute node does not have ref="soapenc:arrayType" // then keep looking. BooleanHolder isRef = new BooleanHolder(); QName refQName = Utils.getTypeQName(kid, isRef, false); if ((refQName != null) && isRef.value && refQName.getLocalPart().equals("arrayType") && Constants.isSOAP_ENC( refQName.getNamespaceURI())) { attributeNode = kid; } } } } // If there is an attribute node, look at wsdl:arrayType to get the element type if (attributeNode != null) { String wsdlArrayTypeValue = null; Vector attrs = Utils.getAttributesWithLocalName(attributeNode, "arrayType"); for (int i = 0; (i < attrs.size()) && (wsdlArrayTypeValue == null); i++) { Node attrNode = (Node) attrs.elementAt(i); String attrName = attrNode.getNodeName(); QName attrQName = Utils.getQNameFromPrefixedName(attributeNode, attrName); if (Constants.isWSDL(attrQName.getNamespaceURI())) { wsdlArrayTypeValue = attrNode.getNodeValue(); } } // The value could have any number of [] or [,] on the end // Strip these off to get the prefixed name. // The convert the prefixed name into a qname. // Count the number of [ and , to get the dim information. if (wsdlArrayTypeValue != null) { int i = wsdlArrayTypeValue.indexOf('['); if (i > 0) { String prefixedName = wsdlArrayTypeValue.substring(0, i); String mangledString = wsdlArrayTypeValue.replace(',', '['); dims.value = 0; int index = mangledString.indexOf('['); while (index > 0) { dims.value++; index = mangledString.indexOf('[', index + 1); } return Utils.getQNameFromPrefixedName(restrictionNode, prefixedName); } } } else if (groupNode != null) { // Get the first element node under the group node. NodeList elements = groupNode.getChildNodes(); Node elementNode = null; for (int i = 0; (i < elements.getLength()) && (elementNode == null); i++) { Node kid = elements.item(i); if (isXSDNode(kid, "element")) { elementNode = elements.item(i); break; } } // The element node should have maxOccurs="unbounded" and // a type if (elementNode != null) { String underlTypeNillableValue = Utils.getAttribute(elementNode, "nillable"); if (underlTypeNillableValue != null && underlTypeNillableValue.equals("true")) { underlTypeNillable.value = true; } String maxOccursValue = Utils.getAttribute(elementNode, "maxOccurs"); if ((maxOccursValue != null) && maxOccursValue.equalsIgnoreCase("unbounded")) { // Get the QName of the type without considering maxOccurs dims.value = 1; return Utils.getTypeQName(elementNode, new BooleanHolder(), true); } } } } return null; } /** * adds an attribute node's type and name to the vector * helper used by getContainedAttributeTypes * * @param v * @param child * @param symbolTable */ private static void addAttributeToVector(Vector v, Node child, SymbolTable symbolTable) { // Get the name and type qnames. // The type qname is used to locate the TypeEntry, which is then // used to retrieve the proper java name of the type. QName attributeName = Utils.getNodeNameQName(child); BooleanHolder forElement = new BooleanHolder(); QName attributeType = Utils.getTypeQName(child, forElement, false); // An attribute is either qualified or unqualified. // If the ref= attribute is used, the name of the ref'd element is used // (which must be a root element). If the ref= attribute is not // used, the name of the attribute is unqualified. if (!forElement.value) { // check the Form (or attributeFormDefault) attribute of // this node to determine if it should be namespace // quailfied or not. String form = Utils.getAttribute(child, "form"); if ((form != null) && form.equals("unqualified")) { // Unqualified nodeName attributeName = Utils.findQName("", attributeName.getLocalPart()); } else if (form == null) { // check attributeFormDefault on schema element String def = Utils.getScopedAttribute(child, "attributeFormDefault"); if ((def == null) || def.equals("unqualified")) { // Unqualified nodeName attributeName = Utils.findQName("", attributeName.getLocalPart()); } } } else { attributeName = attributeType; } // Get the corresponding TypeEntry from the symbol table TypeEntry type = symbolTable.getTypeEntry(attributeType, forElement.value); // Try to get the corresponding global attribute ElementEntry // from the symbol table. if (type instanceof org.apache.axis.wsdl.symbolTable.Element) { type = ((org.apache.axis.wsdl.symbolTable.Element) type).getRefType(); } // add type and name to vector, skip it if we couldn't parse it // XXX - this may need to be revisited. if ((type != null) && (attributeName != null)) { ContainedAttribute attr = new ContainedAttribute(type, attributeName); String useValue = Utils.getAttribute(child, "use"); if (useValue != null) { attr.setOptional(useValue.equalsIgnoreCase("optional")); } v.add(attr); } } /** * adds an attribute to the vector * helper used by addAttributeGroupToVector * * @param v * @param symbolTable * @param type * @param name */ private static void addAttributeToVector(Vector v, SymbolTable symbolTable, QName type, QName name) { TypeEntry typeEnt = symbolTable.getTypeEntry(type, false); if (typeEnt != null) // better not be null { v.add(new ContainedAttribute(typeEnt, name)); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -