1 55 package org.jboss.axis.deployment.wsdd; 56 57 import org.jboss.axis.description.OperationDesc; 58 import org.jboss.axis.description.ParameterDesc; 59 import org.jboss.axis.encoding.SerializationContext; 60 import org.jboss.axis.utils.JavaUtils; 61 import org.jboss.axis.utils.XMLUtils; 62 import org.w3c.dom.Element ; 63 import org.xml.sax.helpers.AttributesImpl ; 64 65 import javax.xml.namespace.QName ; 66 import java.io.IOException ; 67 68 public class WSDDParameter extends WSDDElement 69 { 70 OperationDesc parent; 71 ParameterDesc parameter = new ParameterDesc(); 72 73 public WSDDParameter(Element e, OperationDesc parent) 74 throws WSDDException 75 { 76 super(e); 77 this.parent = parent; 78 79 String nameStr = e.getAttribute(ATTR_QNAME); 83 if (nameStr != null && !nameStr.equals("")) 84 { 85 parameter.setQName(XMLUtils.getQNameFromString(nameStr, e)); 86 } 87 else 88 { 89 nameStr = e.getAttribute(ATTR_NAME); 90 if (nameStr != null && !nameStr.equals("")) 91 { 92 parameter.setQName(new QName (null, nameStr)); 93 } 94 } 95 96 String modeStr = e.getAttribute(ATTR_MODE); 97 if (modeStr != null && !modeStr.equals("")) 98 { 99 parameter.setMode(ParameterDesc.modeFromString(modeStr)); 100 } 101 102 String inHStr = e.getAttribute(ATTR_INHEADER); 103 if (inHStr != null) 104 { 105 parameter.setInHeader(JavaUtils.isTrueExplicitly(inHStr)); 106 } 107 String outHStr = e.getAttribute(ATTR_OUTHEADER); 108 if (outHStr != null) 109 { 110 parameter.setOutHeader(JavaUtils.isTrueExplicitly(outHStr)); 111 } 112 113 String typeStr = e.getAttribute(ATTR_TYPE); 114 if (typeStr != null && !typeStr.equals("")) 115 { 116 parameter.setTypeQName(XMLUtils.getQNameFromString(typeStr, e)); 117 } 118 } 119 120 public WSDDParameter() 121 { 122 } 123 124 public WSDDParameter(ParameterDesc parameter) 125 { 126 this.parameter = parameter; 127 } 128 129 132 public void writeToContext(SerializationContext context) 133 throws IOException 134 { 135 AttributesImpl attrs = new AttributesImpl (); 136 137 QName qname = parameter.getQName(); 138 if (qname != null) 139 { 140 if (qname.getNamespaceURI() != null && 141 !qname.getNamespaceURI().equals("")) 142 { 143 attrs.addAttribute("", ATTR_QNAME, ATTR_QNAME, 144 "CDATA", 145 context.qName2String(parameter.getQName())); 146 } 147 else 148 { 149 attrs.addAttribute("", ATTR_NAME, ATTR_NAME, "CDATA", 150 parameter.getQName().getLocalPart()); 151 } 152 } 153 154 byte mode = parameter.getMode(); 156 if (mode != ParameterDesc.IN) 157 { 158 String modeStr = ParameterDesc.getModeAsString(mode); 159 attrs.addAttribute("", ATTR_MODE, ATTR_MODE, "CDATA", modeStr); 160 } 161 162 if (parameter.isInHeader()) 163 { 164 attrs.addAttribute("", ATTR_INHEADER, ATTR_INHEADER, 165 "CDATA", "true"); 166 } 167 168 if (parameter.isOutHeader()) 169 { 170 attrs.addAttribute("", ATTR_OUTHEADER, ATTR_OUTHEADER, 171 "CDATA", "true"); 172 } 173 174 QName typeQName = parameter.getTypeQName(); 175 if (typeQName != null) 176 { 177 attrs.addAttribute("", ATTR_TYPE, ATTR_TYPE, "CDATA", 178 context.qName2String(typeQName)); 179 } 180 181 context.startElement(getElementName(), attrs); 182 context.endElement(); 183 } 184 185 public ParameterDesc getParameter() 186 { 187 return parameter; 188 } 189 190 public void setParameter(ParameterDesc parameter) 191 { 192 this.parameter = parameter; 193 } 194 195 198 protected QName getElementName() 199 { 200 return WSDDConstants.QNAME_PARAM; 201 } 202 } 203 | Popular Tags |