1 30 31 32 package org.jboss.axis.message; 33 34 35 import org.w3c.dom.Attr ; 36 import org.w3c.dom.DOMException ; 37 import org.w3c.dom.Document ; 38 import org.w3c.dom.NamedNodeMap ; 39 import org.w3c.dom.Node ; 40 41 import java.util.Iterator ; 42 import java.util.Vector ; 43 44 45 50 51 public class NamedNodeMapImpl implements NamedNodeMap 52 { 53 54 55 58 59 protected Vector nodes; 60 61 62 static private Document doc = null; 63 64 static 65 { 66 67 try 68 { 69 70 org.w3c.dom.Document doc = org.jboss.axis.utils.XMLUtils.newDocument(); 71 72 } 73 catch (javax.xml.parsers.ParserConfigurationException e) 74 { 75 76 throw new org.jboss.axis.InternalException(e); 77 78 } 79 80 } 81 82 83 public NamedNodeMapImpl() 84 85 { 86 87 nodes = new Vector (); 88 89 } 90 91 101 102 public Node getNamedItem(String name) 103 { 104 105 if (name == null) 106 { 107 108 Thread.dumpStack(); 109 110 throw new java.lang.IllegalArgumentException ("local name = null"); 111 112 } 113 114 115 for (Iterator iter = nodes.iterator(); iter.hasNext();) 116 { 117 118 Attr attr = (Attr )iter.next(); 119 120 if (name.equals(attr.getName())) 121 { 122 123 return attr; 124 125 } 126 127 } 128 129 return null; 130 131 } 132 133 134 183 184 public Node setNamedItem(Node arg) throws DOMException 185 186 { 187 188 189 String name = arg.getNodeName(); 190 191 192 if (name == null) 193 { 194 195 Thread.dumpStack(); 196 197 throw new java.lang.IllegalArgumentException ("local name = null"); 198 199 } 200 201 202 for (int i = 0; i < nodes.size(); i++) 203 { 204 205 Attr attr = (Attr )nodes.get(i); 206 207 209 if (name.equals(attr.getName())) 210 { 211 212 nodes.remove(i); 213 214 nodes.add(i, arg); 215 216 return attr; 218 } 219 220 } 221 222 223 224 226 nodes.add(arg); 227 228 return null; 229 230 } 231 232 233 254 255 public Node removeNamedItem(String name) throws DOMException 256 257 { 258 259 if (name == null) 260 { 261 262 Thread.dumpStack(); 263 264 throw new java.lang.IllegalArgumentException ("local name = null"); 265 266 } 267 268 for (int i = 0; i < nodes.size(); i++) 269 { 270 271 Attr attr = (Attr )nodes.get(i); 272 273 275 if (name.equals(attr.getLocalName())) 276 { 277 278 nodes.remove(i); 279 280 return attr; 282 } 283 284 } 285 286 return null; 287 288 } 289 290 291 303 304 public Node item(int index) 305 { 306 307 return (nodes != null && index < nodes.size()) ? 308 309 (Node )(nodes.elementAt(index)) : null; 310 311 } 312 313 314 319 320 public int getLength() 321 { 322 323 return (nodes != null) ? nodes.size() : 0; 324 325 } 326 327 328 348 349 public Node getNamedItemNS(String namespaceURI, String localName) 350 { 351 352 353 if (namespaceURI == null) namespaceURI = ""; 354 355 if (localName == null) 356 { 357 358 Thread.dumpStack(); 359 360 throw new java.lang.IllegalArgumentException ("local name = null"); 361 362 } 363 364 365 for (Iterator iter = nodes.iterator(); iter.hasNext();) 366 { 367 368 Attr attr = (Attr )iter.next(); 369 370 if (namespaceURI.equals(attr.getNamespaceURI()) && 371 372 namespaceURI.equals(attr.getLocalName())) 373 { 374 375 return attr; 376 377 } 378 379 } 380 381 return null; 382 383 } 384 385 386 436 437 public Node setNamedItemNS(Node arg) throws DOMException 438 439 { 440 441 String namespaceURI = arg.getNamespaceURI(); 442 443 String localName = arg.getLocalName(); 444 445 446 if (namespaceURI == null) namespaceURI = ""; 447 448 if (localName == null) 449 { 450 451 Thread.dumpStack(); 452 453 throw new java.lang.IllegalArgumentException ("local name = null"); 454 455 } 456 457 458 for (int i = 0; i < nodes.size(); i++) 459 { 460 461 Attr attr = (Attr )nodes.get(i); 462 463 465 if (namespaceURI.equals(attr.getNamespaceURI()) && 466 467 namespaceURI.equals(attr.getLocalName())) 468 { 469 470 nodes.remove(i); 471 472 nodes.add(i, arg); 473 474 return attr; 476 } 477 478 } 479 480 481 482 484 nodes.add(arg); 485 486 return null; 487 488 } 489 490 491 524 525 public Node removeNamedItemNS(String namespaceURI, String localName) throws DOMException 526 { 527 528 529 if (namespaceURI == null) namespaceURI = ""; 530 531 if (localName == null) 532 { 533 534 Thread.dumpStack(); 535 536 throw new java.lang.IllegalArgumentException ("local name = null"); 537 538 } 539 540 541 for (int i = 0; i < nodes.size(); i++) 542 { 543 544 Attr attr = (Attr )nodes.get(i); 545 546 548 if (namespaceURI.equals(attr.getNamespaceURI()) && 549 550 localName.equals(attr.getLocalName())) 551 { 552 553 nodes.remove(i); 554 555 return attr; 557 } 558 559 } 560 561 return null; 562 563 564 } 565 566 567 } 568 569 | Popular Tags |