1 16 package org.jboss.axis.message; 17 18 20 import org.jboss.axis.NotImplementedException; 21 import org.jboss.axis.utils.DOM2Utils; 22 import org.jboss.logging.Logger; 23 import org.w3c.dom.Attr ; 24 import org.w3c.dom.DOMException ; 25 import org.w3c.dom.Element ; 26 import org.w3c.dom.NamedNodeMap ; 27 import org.w3c.dom.NodeList ; 28 import org.w3c.dom.TypeInfo ; 29 30 import javax.xml.soap.Name ; 31 import javax.xml.soap.SOAPElement ; 32 import javax.xml.soap.SOAPException ; 33 import java.util.ArrayList ; 34 import java.util.Iterator ; 35 36 44 public class SOAPElementImpl extends NodeImpl implements SOAPElement 45 { 46 47 private static Logger log = Logger.getLogger(SOAPElement .class.getName()); 49 50 private Element element; 52 53 56 public SOAPElementImpl(String localPart) 57 { 58 super(DOM2Utils.createElement(null, localPart)); 59 element = (Element )domNode; 60 } 61 62 65 public SOAPElementImpl(String localPart, String prefix, String namespace) 66 { 67 super(DOM2Utils.createElement(null, namespace, prefix, localPart)); 68 element = (Element )domNode; 69 } 70 71 74 public SOAPElementImpl(Name name) 75 { 76 super(DOM2Utils.createElement(null, name)); 77 element = (Element )domNode; 78 } 79 80 82 SOAPElementImpl(Element element) 83 { 84 super(element); 85 this.element = element; 86 } 87 88 90 98 public SOAPElement addAttribute(Name name, String value) throws SOAPException 99 { 100 setAttributeNS(name.getURI(), name.getQualifiedName(), value); 101 return this; 102 } 103 104 111 public SOAPElement addChildElement(String name) throws SOAPException 112 { 113 SOAPElement soapElement = new SOAPElementImpl(name); 114 addChildElement(soapElement); 115 return soapElement; 116 } 117 118 126 public SOAPElement addChildElement(String localName, String prefix) throws SOAPException 127 { 128 SOAPElement soapElement = new SOAPElementImpl(localName, prefix, null); 129 addChildElement(soapElement); 130 return soapElement; 131 } 132 133 142 public SOAPElement addChildElement(String localName, String prefix, String uri) throws SOAPException 143 { 144 SOAPElement soapElement = new SOAPElementImpl(localName, prefix, uri); 145 addChildElement(soapElement); 146 return soapElement; 147 } 148 149 156 public SOAPElement addChildElement(Name name) throws SOAPException 157 { 158 SOAPElement soapElement = new SOAPElementImpl(name); 159 addChildElement(soapElement); 160 return soapElement; 161 } 162 163 179 public SOAPElement addChildElement(SOAPElement child) throws SOAPException 180 { 181 element.appendChild(child); 182 return new SOAPElementAxisImpl(child); 183 } 184 185 193 public SOAPElement addNamespaceDeclaration(String prefix, String uri) throws SOAPException 194 { 195 element.setAttribute("xmlns:" + prefix, uri); 196 return this; 197 } 198 199 206 public SOAPElement addTextNode(String value) throws SOAPException 207 { 208 org.w3c.dom.Text domText = element.getOwnerDocument().createTextNode(value); 209 javax.xml.soap.Text soapText = new TextImpl(domText); 210 appendChild(soapText); 211 return this; 212 } 213 214 222 public Iterator getAllAttributes() 223 { 224 ArrayList list = new ArrayList (); 225 NamedNodeMap nnm = getAttributes(); 226 for (int i = 0; i < nnm.getLength(); i++) 227 { 228 org.w3c.dom.Node node = (org.w3c.dom.Node )nnm.item(i); 229 String local = node.getLocalName(); 230 String prefix = node.getPrefix(); 231 String uri = node.getNamespaceURI(); 232 list.add(new NameImpl(local, prefix, uri)); 233 } 234 return list.iterator(); 235 } 236 237 243 public String getAttributeValue(Name name) 244 { 245 throw new NotImplementedException(); 246 } 247 248 260 public Iterator getChildElements() 261 { 262 throw new NotImplementedException(); 263 } 264 265 278 public Iterator getChildElements(Name name) 279 { 280 throw new NotImplementedException(); 281 } 282 283 288 public Name getElementName() 289 { 290 throw new NotImplementedException(); 291 } 292 293 298 public String getEncodingStyle() 299 { 300 throw new NotImplementedException(); 301 } 302 303 310 public Iterator getNamespacePrefixes() 311 { 312 throw new NotImplementedException(); 313 } 314 315 321 public String getNamespaceURI(String prefix) 322 { 323 throw new NotImplementedException(); 324 } 325 326 333 public Iterator getVisibleNamespacePrefixes() 334 { 335 throw new NotImplementedException(); 336 } 337 338 344 public boolean removeAttribute(Name name) 345 { 346 throw new NotImplementedException(); 347 } 348 349 356 public void removeContents() 357 { 358 throw new NotImplementedException(); 359 } 360 361 367 public boolean removeNamespaceDeclaration(String prefix) 368 { 369 throw new NotImplementedException(); 370 } 371 372 378 public void setEncodingStyle(String encodingStyle) throws SOAPException 379 { 380 throw new NotImplementedException(); 381 } 382 383 385 public String getTagName() 386 { 387 return element.getTagName(); 388 } 389 390 public void removeAttribute(String name) throws DOMException 391 { 392 element.removeAttribute(name); 393 } 394 395 public boolean hasAttribute(String name) 396 { 397 return element.hasAttribute(name); 398 } 399 400 public String getAttribute(String name) 401 { 402 return element.getAttribute(name); 403 } 404 405 public void removeAttributeNS(String namespaceURI, String localName) throws DOMException 406 { 407 element.removeAttributeNS(namespaceURI, localName); 408 } 409 410 public void setAttribute(String name, String value) throws DOMException 411 { 412 element.setAttribute(name, value); 413 } 414 415 public boolean hasAttributeNS(String namespaceURI, String localName) 416 { 417 return element.hasAttributeNS(namespaceURI, localName); 418 } 419 420 public Attr getAttributeNode(String name) 421 { 422 return element.getAttributeNode(name); 423 } 424 425 public Attr removeAttributeNode(Attr oldAttr) throws DOMException 426 { 427 return element.removeAttributeNode(oldAttr); 428 } 429 430 public Attr setAttributeNode(Attr newAttr) throws DOMException 431 { 432 return element.setAttributeNode(newAttr); 433 } 434 435 public Attr setAttributeNodeNS(Attr newAttr) throws DOMException 436 { 437 return element.setAttributeNodeNS(newAttr); 438 } 439 440 public NodeList getElementsByTagName(String name) 441 { 442 return element.getElementsByTagName(name); 443 } 444 445 public String getAttributeNS(String namespaceURI, String localName) 446 { 447 return element.getAttributeNS(namespaceURI, localName); 448 } 449 450 public void setAttributeNS(String namespaceURI, String qualifiedName, String value) throws DOMException 451 { 452 element.setAttributeNS(namespaceURI, qualifiedName, value); 453 } 454 455 public Attr getAttributeNodeNS(String namespaceURI, String localName) 456 { 457 return element.getAttributeNodeNS(namespaceURI, localName); 458 } 459 460 public NodeList getElementsByTagNameNS(String namespaceURI, String localName) 461 { 462 return element.getElementsByTagNameNS(namespaceURI, localName); 463 } 464 465 public TypeInfo getSchemaTypeInfo() 467 { 468 return null; 469 } 470 471 public void setIdAttribute(String name, boolean isId) throws DOMException 472 { 473 474 } 475 476 public void setIdAttributeNS(String namespaceURI, String localName, boolean isId) throws DOMException 477 { 478 479 } 480 481 public void setIdAttributeNode(Attr idAttr, boolean isId) throws DOMException 482 { 483 484 } 485 } 487 | Popular Tags |