01: /*
02: * Copyright 2007 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package com.google.gwt.xml.client.impl;
17:
18: import com.google.gwt.core.client.JavaScriptException;
19: import com.google.gwt.core.client.JavaScriptObject;
20: import com.google.gwt.xml.client.DOMException;
21: import com.google.gwt.xml.client.NamedNodeMap;
22: import com.google.gwt.xml.client.Node;
23:
24: /**
25: * This class implements the NamedNodeMap interface.
26: */
27: class NamedNodeMapImpl extends NodeListImpl implements NamedNodeMap {
28:
29: protected NamedNodeMapImpl(JavaScriptObject o) {
30: super (o);
31: }
32:
33: /**
34: * Gets the number of nodes in this object.
35: *
36: * @return the number of nodes in this object.
37: * @see com.google.gwt.xml.client.impl.NodeListImpl#getLength()
38: */
39: @Override
40: public int getLength() {
41: return super .getLength();
42: }
43:
44: /**
45: * This method gets the item at the index position.
46: *
47: * @param name - the name of the item
48: * @return the item retrieved from the name
49: */
50: public Node getNamedItem(String name) {
51: return NodeImpl.build(XMLParserImpl.getNamedItem(this
52: .getJsObject(), name));
53: }
54:
55: @Override
56: public Node item(int index) {
57: return super .item(index);
58: }
59:
60: /**
61: * This function delegates to the native method <code>removeNamedItem</code>
62: * in XMLParserImpl.
63: */
64: public Node removeNamedItem(String name) {
65: try {
66: return NodeImpl.build(XMLParserImpl.removeNamedItem(this
67: .getJsObject(), name));
68: } catch (JavaScriptException e) {
69: throw new DOMNodeException(
70: DOMException.INVALID_MODIFICATION_ERR, e, this );
71: }
72: }
73:
74: /**
75: * This function delegates to the native method <code>setNamedItem</code> in
76: * XMLParserImpl.
77: */
78: public Node setNamedItem(Node arg) {
79: try {
80: return NodeImpl.build(XMLParserImpl.setNamedItem(this
81: .getJsObject(), ((DOMItem) arg).getJsObject()));
82: } catch (JavaScriptException e) {
83: throw new DOMNodeException(
84: DOMException.INVALID_MODIFICATION_ERR, e, this);
85: }
86: }
87: }
|