1 16 package org.apache.axis.deployment.wsdd; 17 18 import org.apache.axis.description.OperationDesc; 19 import org.apache.axis.description.ParameterDesc; 20 import org.apache.axis.encoding.SerializationContext; 21 import org.apache.axis.utils.JavaUtils; 22 import org.apache.axis.utils.XMLUtils; 23 import org.w3c.dom.Element ; 24 import org.xml.sax.helpers.AttributesImpl ; 25 26 import javax.xml.namespace.QName ; 27 import java.io.IOException ; 28 29 public class WSDDParameter extends WSDDElement 30 { 31 OperationDesc parent; 32 ParameterDesc parameter = new ParameterDesc(); 33 34 public WSDDParameter(Element e, OperationDesc parent) 35 throws WSDDException { 36 super(e); 37 this.parent = parent; 38 39 String nameStr = e.getAttribute(ATTR_QNAME); 43 if (nameStr != null && !nameStr.equals("")) { 44 parameter.setQName(XMLUtils.getQNameFromString(nameStr, e)); 45 } else { 46 nameStr = e.getAttribute(ATTR_NAME); 47 if (nameStr != null && !nameStr.equals("")) { 48 parameter.setQName(new QName (null, nameStr)); 49 } 50 } 51 52 String modeStr = e.getAttribute(ATTR_MODE); 53 if (modeStr != null && !modeStr.equals("")) { 54 parameter.setMode(ParameterDesc.modeFromString(modeStr)); 55 } 56 57 String inHStr = e.getAttribute(ATTR_INHEADER); 58 if (inHStr != null) { 59 parameter.setInHeader(JavaUtils.isTrueExplicitly(inHStr)); 60 } 61 String outHStr = e.getAttribute(ATTR_OUTHEADER); 62 if (outHStr != null) { 63 parameter.setOutHeader(JavaUtils.isTrueExplicitly(outHStr)); 64 } 65 66 String typeStr = e.getAttribute(ATTR_TYPE); 67 if (typeStr != null && !typeStr.equals("")) { 68 parameter.setTypeQName(XMLUtils.getQNameFromString(typeStr, e)); 69 } 70 71 String itemQNameStr = e.getAttribute(ATTR_ITEMQNAME); 72 if (itemQNameStr != null && !itemQNameStr.equals("")) { 73 parameter.setItemQName(XMLUtils.getQNameFromString(itemQNameStr, e)); 74 } 75 76 String itemTypeStr = e.getAttribute(ATTR_ITEMTYPE); 77 if (itemTypeStr != null && !itemTypeStr.equals("")) { 78 parameter.setItemType(XMLUtils.getQNameFromString(itemTypeStr, e)); 79 } 80 81 Element docElem = getChildElement(e, ELEM_WSDD_DOC); 82 if (docElem != null) { 83 WSDDDocumentation documentation = new WSDDDocumentation(docElem); 84 parameter.setDocumentation(documentation.getValue()); 85 } 86 } 87 88 public WSDDParameter() { 89 } 90 91 public WSDDParameter(ParameterDesc parameter) { 92 this.parameter = parameter; 93 } 94 95 98 public void writeToContext(SerializationContext context) 99 throws IOException { 100 AttributesImpl attrs = new AttributesImpl (); 101 102 QName qname = parameter.getQName(); 103 if (qname != null) { 104 if (qname.getNamespaceURI() != null && 105 !qname.getNamespaceURI().equals("")) { 106 attrs.addAttribute("", ATTR_QNAME, ATTR_QNAME, 107 "CDATA", 108 context.qName2String(parameter.getQName())); 109 } else { 110 attrs.addAttribute("", ATTR_NAME, ATTR_NAME, "CDATA", 111 parameter.getQName().getLocalPart()); 112 } 113 } 114 115 byte mode = parameter.getMode(); 117 if (mode != ParameterDesc.IN) { 118 String modeStr = ParameterDesc.getModeAsString(mode); 119 attrs.addAttribute("", ATTR_MODE, ATTR_MODE, "CDATA", modeStr); 120 } 121 122 if (parameter.isInHeader()) { 123 attrs.addAttribute("", ATTR_INHEADER, ATTR_INHEADER, 124 "CDATA", "true"); 125 } 126 127 if (parameter.isOutHeader()) { 128 attrs.addAttribute("", ATTR_OUTHEADER, ATTR_OUTHEADER, 129 "CDATA", "true"); 130 } 131 132 QName typeQName = parameter.getTypeQName(); 133 if (typeQName != null) { 134 attrs.addAttribute("", ATTR_TYPE, ATTR_TYPE, "CDATA", 135 context.qName2String(typeQName)); 136 } 137 138 QName itemQName = parameter.getItemQName(); 139 if (itemQName != null) { 140 attrs.addAttribute("", ATTR_ITEMQNAME, ATTR_ITEMQNAME, "CDATA", 141 context.qName2String(itemQName)); 142 } 143 144 QName itemType = parameter.getItemType(); 145 if (itemType != null) { 146 attrs.addAttribute("", ATTR_ITEMTYPE, ATTR_ITEMTYPE, "CDATA", 147 context.qName2String(itemType)); 148 } 149 150 context.startElement(getElementName(), attrs); 151 152 if (parameter.getDocumentation() != null) { 153 WSDDDocumentation documentation = new WSDDDocumentation(parameter.getDocumentation()); 154 documentation.writeToContext(context); 155 } 156 157 context.endElement(); 158 } 159 160 public ParameterDesc getParameter() { 161 return parameter; 162 } 163 164 public void setParameter(ParameterDesc parameter) { 165 this.parameter = parameter; 166 } 167 168 171 protected QName getElementName() { 172 return WSDDConstants.QNAME_PARAM; 173 } 174 } 175 | Popular Tags |