KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > xml > client > impl > NamedNodeMapImpl


1 /*
2  * Copyright 2006 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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   public int getLength() {
40     return super.getLength();
41   }
42
43   /**
44    * This method gets the item at the index position.
45    *
46    * @param name - the name of the item
47    * @return the item retrieved from the name
48    */

49   public Node getNamedItem(String JavaDoc name) {
50     return NodeImpl.build(XMLParserImpl.getNamedItem(this.getJsObject(), name));
51   }
52
53   public Node item(int index) {
54     return super.item(index);
55   }
56
57   /**
58    * This function delegates to the native method <code>removeNamedItem</code>
59    * in XMLParserImpl.
60    */

61   public Node removeNamedItem(String JavaDoc name) {
62     try {
63       return NodeImpl.build(XMLParserImpl.removeNamedItem(this.getJsObject(),
64         name));
65     } catch (JavaScriptException e) {
66       throw new DOMNodeException(DOMException.INVALID_MODIFICATION_ERR, e, this);
67     }
68   }
69
70   /**
71    * This function delegates to the native method <code>setNamedItem</code> in
72    * XMLParserImpl.
73    */

74   public Node setNamedItem(Node arg) {
75     try {
76       return NodeImpl.build(XMLParserImpl.setNamedItem(this.getJsObject(),
77         ((DOMItem) arg).getJsObject()));
78     } catch (JavaScriptException e) {
79       throw new DOMNodeException(DOMException.INVALID_MODIFICATION_ERR, e, this);
80     }
81   }
82 }
83
Popular Tags