1 16 19 package org.apache.xml.dtm.ref; 20 21 import org.apache.xml.dtm.DTM; 22 23 import org.w3c.dom.DOMException ; 24 import org.w3c.dom.NamedNodeMap ; 25 import org.w3c.dom.Node ; 26 27 42 public class DTMNamedNodeMap implements NamedNodeMap 43 { 44 45 46 DTM dtm; 47 48 49 int element; 50 51 52 short m_count = -1; 53 54 60 public DTMNamedNodeMap(DTM dtm, int element) 61 { 62 this.dtm = dtm; 63 this.element = element; 64 } 65 66 71 public int getLength() 72 { 73 74 if (m_count == -1) 75 { 76 short count = 0; 77 78 for (int n = dtm.getFirstAttribute(element); n != -1; 79 n = dtm.getNextAttribute(n)) 80 { 81 ++count; 82 } 83 84 m_count = count; 85 } 86 87 return (int) m_count; 88 } 89 90 99 public Node getNamedItem(String name) 100 { 101 102 for (int n = dtm.getFirstAttribute(element); n != -1; 103 n = dtm.getNextAttribute(n)) 104 { 105 if (dtm.getNodeName(n).equals(name)) 106 return dtm.getNode(n); 107 } 108 109 return null; 110 } 111 112 122 public Node item(int i) 123 { 124 125 int count = 0; 126 127 for (int n = dtm.getFirstAttribute(element); n != -1; 128 n = dtm.getNextAttribute(n)) 129 { 130 if (count == i) 131 return dtm.getNode(n); 132 else 133 ++count; 134 } 135 136 return null; 137 } 138 139 163 public Node setNamedItem(Node newNode) 164 { 165 throw new DTMException(DTMException.NO_MODIFICATION_ALLOWED_ERR); 166 } 167 168 183 public Node removeNamedItem(String name) 184 { 185 throw new DTMException(DTMException.NO_MODIFICATION_ALLOWED_ERR); 186 } 187 188 199 public Node getNamedItemNS(String namespaceURI, String localName) 200 { 201 throw new DTMException(DTMException.NOT_SUPPORTED_ERR); 202 } 203 204 227 public Node setNamedItemNS(Node arg) throws DOMException 228 { 229 throw new DTMException(DTMException.NO_MODIFICATION_ALLOWED_ERR); 230 } 231 232 252 public Node removeNamedItemNS(String namespaceURI, String localName) 253 throws DOMException 254 { 255 throw new DTMException(DTMException.NO_MODIFICATION_ALLOWED_ERR); 256 } 257 258 262 public class DTMException extends org.w3c.dom.DOMException 263 { 264 265 271 public DTMException(short code, String message) 272 { 273 super(code, message); 274 } 275 276 282 public DTMException(short code) 283 { 284 super(code, ""); 285 } 286 } 287 } 288 | Popular Tags |