1 16 17 package org.apache.axis.message; 18 19 import org.w3c.dom.Attr ; 20 import org.w3c.dom.DOMException ; 21 import org.w3c.dom.Document ; 22 import org.w3c.dom.NamedNodeMap ; 23 import org.w3c.dom.Node ; 24 25 import java.util.Iterator ; 26 import java.util.Vector ; 27 28 33 public class NamedNodeMapImpl implements NamedNodeMap { 34 35 36 37 protected Vector nodes; 38 39 static private Document doc = null; 40 static{ 41 try { 42 org.w3c.dom.Document doc = org.apache.axis.utils.XMLUtils.newDocument(); 43 } catch (javax.xml.parsers.ParserConfigurationException e) { 44 throw new org.apache.axis.InternalException(e); 45 } 46 } 47 48 public NamedNodeMapImpl() 49 { 50 nodes = new Vector (); 51 } 52 59 public Node getNamedItem(String name){ 60 if(name == null ){ 61 Thread.dumpStack(); 62 throw new java.lang.IllegalArgumentException ("local name = null"); 63 } 64 65 for(Iterator iter = nodes.iterator(); iter.hasNext();){ 66 Attr attr = (Attr )iter.next(); 67 if(name.equals(attr.getName())){ 68 return attr; 69 } 70 } 71 return null; 72 } 73 74 102 public Node setNamedItem(Node arg) throws DOMException 103 { 104 105 String name = arg.getNodeName(); 106 107 if(name == null ){ 108 Thread.dumpStack(); 109 throw new java.lang.IllegalArgumentException ("local name = null"); 110 } 111 112 for(int i = 0; i < nodes.size(); i++){ 113 Attr attr = (Attr )nodes.get(i); 114 if(name.equals(attr.getName())){ 116 nodes.remove(i); 117 nodes.add(i, arg); 118 return attr; } 120 } 121 122 nodes.add(arg); 124 return null; 125 } 126 127 141 public Node removeNamedItem(String name) throws DOMException 142 { 143 if(name == null ){ 144 Thread.dumpStack(); 145 throw new java.lang.IllegalArgumentException ("local name = null"); 146 } 147 for(int i = 0; i < nodes.size(); i++){ 148 Attr attr = (Attr )nodes.get(i); 149 if(name.equals(attr.getLocalName())){ 151 nodes.remove(i); 152 return attr; } 154 } 155 return null; 156 } 157 158 166 public Node item(int index){ 167 return (nodes != null && index < nodes.size()) ? 168 (Node )(nodes.elementAt(index)) : null; 169 } 170 171 175 public int getLength(){ 176 return (nodes != null) ? nodes.size() : 0; 177 } 178 179 192 public Node getNamedItemNS(String namespaceURI, String localName){ 193 194 if(namespaceURI == null) namespaceURI = ""; 195 if(localName == null ){ 196 Thread.dumpStack(); 197 throw new java.lang.IllegalArgumentException ("local name = null"); 198 } 199 200 for(Iterator iter = nodes.iterator(); iter.hasNext();){ 201 Attr attr = (Attr )iter.next(); 202 if(namespaceURI.equals(attr.getNamespaceURI()) && 203 localName.equals(attr.getLocalName())){ 204 return attr; 205 } 206 } 207 return null; 208 } 209 210 239 public Node setNamedItemNS(Node arg) throws DOMException 240 { 241 String namespaceURI = arg.getNamespaceURI(); 242 String localName = arg.getLocalName(); 243 244 if(namespaceURI == null) namespaceURI = ""; 245 if(localName == null ){ 246 Thread.dumpStack(); 247 throw new java.lang.IllegalArgumentException ("local name = null"); 248 } 249 250 for(int i = 0; i < nodes.size(); i++){ 251 Attr attr = (Attr )nodes.get(i); 252 if(namespaceURI.equals(attr.getNamespaceURI()) && 254 namespaceURI.equals(attr.getLocalName())){ 255 nodes.remove(i); 256 nodes.add(i, arg); 257 return attr; } 259 } 260 261 nodes.add(arg); 263 return null; 264 } 265 266 287 public Node removeNamedItemNS(String namespaceURI, String localName) throws DOMException { 288 289 if(namespaceURI == null) namespaceURI = ""; 290 if(localName == null ){ 291 Thread.dumpStack(); 292 throw new java.lang.IllegalArgumentException ("local name = null"); 293 } 294 295 for(int i = 0; i < nodes.size(); i++){ 296 Attr attr = (Attr )nodes.get(i); 297 if(namespaceURI.equals(attr.getNamespaceURI()) && 299 localName.equals(attr.getLocalName())){ 300 nodes.remove(i); 301 return attr; } 303 } 304 return null; 305 306 } 307 308 309 } 310 | Popular Tags |