1 20 21 25 26 package org.ozoneDB.xml.dom; 27 28 import java.util.*; 29 import java.io.*; 30 import org.w3c.dom.*; 31 import org.ozoneDB.OzoneObject; 32 33 34 52 public final class NamedNodeMapImpl extends OzoneObject implements NamedNodeMapProxy, Externalizable { 53 54 final static long serialVersionUID = 1; 55 56 57 public Node getNamedItemNS( java.lang.String namespaceURI, java.lang.String localName ) { 58 throw new DOMExceptionImpl( DOMException.NOT_SUPPORTED_ERR, 59 "NamedNode.getNamedItemNS(): ozone's persistent DOM doesn't support DOM level 2 yet." ); 60 } 61 62 63 public Node setNamedItemNS( Node arg ) throws DOMException { 64 throw new DOMExceptionImpl( DOMException.NOT_SUPPORTED_ERR, 65 "NamedNode.getNamedItemNS(): ozone's persistent DOM doesn't support DOM level 2 yet." ); 66 } 67 68 69 public Node removeNamedItemNS( java.lang.String namespaceURI, java.lang.String localName ) throws DOMException { 70 throw new DOMExceptionImpl( DOMException.NOT_SUPPORTED_ERR, 71 "NamedNode.getNamedItemNS(): ozone's persistent DOM doesn't support DOM level 2 yet." ); 72 } 73 74 75 public synchronized Node getNamedItem( String name ) { 76 return (Node)_dictionary.get( name ); 78 } 79 80 81 public synchronized Node setNamedItem( Node arg ) throws DOMException { 82 if (_owner.isReadOnly()) { 85 throw new DOMExceptionImpl( DOMException.NO_MODIFICATION_ALLOWED_ERR ); 86 } 87 if (arg == null || !(arg instanceof Node)) { 88 throw new DOMExceptionImpl( DOMException.WRONG_DOCUMENT_ERR ); 89 } 90 if (!(arg instanceof ElementDeclProxy || arg instanceof Notation || arg instanceof Entity)) { 91 throw new DOMExceptionImpl( DOMException.WRONG_DOCUMENT_ERR ); 92 } 93 return (Node)_dictionary.put( arg.getNodeName(), arg ); 94 } 95 96 97 public synchronized Node removeNamedItem( String name ) throws DOMException { 98 if (_owner.isReadOnly()) { 99 throw new DOMExceptionImpl( DOMException.NO_MODIFICATION_ALLOWED_ERR ); 100 } 101 return (Node)_dictionary.remove( name ); 102 } 103 104 105 public synchronized Node item( int index ) { 106 Enumeration elem; 107 108 elem = _dictionary.elements(); 112 while (elem.hasMoreElements()) { 113 if (index == 0) { 114 return (Node)elem.nextElement(); 115 } 116 elem.nextElement(); 117 --index; 118 } 119 return null; 120 } 121 122 123 public int getLength() { 124 return _dictionary.size(); 125 } 126 127 128 135 public Enumeration elements() { 136 return _dictionary.elements(); 137 } 138 139 140 147 public NamedNodeMapImpl( NodeProxy owner, Dictionary dictionary ) { 148 init( owner, dictionary ); 149 } 150 151 152 public NamedNodeMapImpl() { 153 super(); 154 } 155 156 157 public void init( NodeProxy owner, Dictionary dictionary ) { 158 if (owner == null || dictionary == null) { 159 throw new NullPointerException ( "Argument 'owner' or 'dictionary' is null." ); 160 } 161 _dictionary = dictionary; 162 _owner = owner; 163 } 164 165 166 167 public void writeExternal( ObjectOutput out ) throws IOException { 168 out.writeObject( _dictionary ); 170 out.writeObject( _owner ); 171 } 172 173 174 175 public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { 176 _dictionary = (Dictionary)in.readObject(); 178 _owner = (NodeProxy)in.readObject(); 179 } 180 181 185 private Dictionary _dictionary; 186 187 188 192 private NodeProxy _owner; 193 } 194 | Popular Tags |