KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > quercus > lib > dom > DOMElement


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Sam
28  */

29
30 package com.caucho.quercus.lib.dom;
31
32 import com.caucho.quercus.annotation.Optional;
33 import com.caucho.quercus.env.Env;
34
35 import org.w3c.dom.Element JavaDoc;
36
37 public class DOMElement
38   extends DOMNode<Element JavaDoc>
39 {
40   public static DOMElement __construct(Env env, String JavaDoc name, @Optional String JavaDoc textContent, @Optional String JavaDoc namespace)
41   {
42     DOMElement element;
43
44     if (namespace != null && namespace.length() > 0)
45       element = getImpl(env).createElement(name, namespace);
46     else
47       element = getImpl(env).createElement(name);
48
49     if (textContent != null && textContent.length() > 0)
50       element.setTextContent(textContent);
51
52     return element;
53   }
54
55   DOMElement(DOMImplementation impl, Element JavaDoc node)
56   {
57     super(impl, node);
58   }
59
60   public String JavaDoc getAttribute(String JavaDoc name)
61   {
62     return _delegate.getAttribute(name);
63   }
64
65   public String JavaDoc getAttributeNS(String JavaDoc namespaceURI, String JavaDoc localName)
66     throws DOMException
67   {
68     try {
69       return _delegate.getAttributeNS(namespaceURI, localName);
70     }
71     catch (org.w3c.dom.DOMException JavaDoc ex) {
72       throw wrap(ex);
73     }
74   }
75
76   public DOMAttr getAttributeNode(String JavaDoc name)
77   {
78     return wrap(_delegate.getAttributeNode(name));
79   }
80
81   public DOMAttr getAttributeNodeNS(String JavaDoc namespaceURI, String JavaDoc localName)
82     throws DOMException
83   {
84     try {
85       return wrap(_delegate.getAttributeNodeNS(namespaceURI, localName));
86     }
87     catch (org.w3c.dom.DOMException JavaDoc ex) {
88       throw wrap(ex);
89     }
90   }
91
92   public DOMNodeList getElementsByTagName(String JavaDoc name)
93   {
94     return wrap(_delegate.getElementsByTagName(name));
95   }
96
97   public DOMNodeList getElementsByTagNameNS(String JavaDoc namespaceURI, String JavaDoc localName)
98     throws DOMException
99   {
100     try {
101       return wrap(_delegate.getElementsByTagNameNS(namespaceURI, localName));
102     }
103     catch (org.w3c.dom.DOMException JavaDoc ex) {
104       throw wrap(ex);
105     }
106   }
107
108   public DOMTypeInfo getSchemaTypeInfo()
109   {
110     return wrap(_delegate.getSchemaTypeInfo());
111   }
112
113   public String JavaDoc getTagName()
114   {
115     return _delegate.getTagName();
116   }
117
118   public boolean hasAttribute(String JavaDoc name)
119   {
120     return _delegate.hasAttribute(name);
121   }
122
123   public boolean hasAttributeNS(String JavaDoc namespaceURI, String JavaDoc localName)
124     throws DOMException
125   {
126     try {
127       return _delegate.hasAttributeNS(namespaceURI, localName);
128     }
129     catch (org.w3c.dom.DOMException JavaDoc ex) {
130       throw wrap(ex);
131     }
132   }
133
134   public void removeAttribute(String JavaDoc name)
135     throws DOMException
136   {
137     try {
138       _delegate.removeAttribute(name);
139     }
140     catch (org.w3c.dom.DOMException JavaDoc ex) {
141       throw wrap(ex);
142     }
143   }
144
145   public void removeAttributeNS(String JavaDoc namespaceURI, String JavaDoc localName)
146     throws DOMException
147   {
148     try {
149       _delegate.removeAttributeNS(namespaceURI, localName);
150     }
151     catch (org.w3c.dom.DOMException JavaDoc ex) {
152       throw wrap(ex);
153     }
154   }
155
156   public DOMAttr removeAttributeNode(DOMAttr oldAttr)
157     throws DOMException
158   {
159     try {
160       return wrap(_delegate.removeAttributeNode(oldAttr._delegate));
161     }
162     catch (org.w3c.dom.DOMException JavaDoc ex) {
163       throw wrap(ex);
164     }
165   }
166
167   public void setAttribute(String JavaDoc name, String JavaDoc value)
168     throws DOMException
169   {
170     try {
171       _delegate.setAttribute(name, value);
172     }
173     catch (org.w3c.dom.DOMException JavaDoc ex) {
174       throw wrap(ex);
175     }
176   }
177
178   public void setAttributeNS(String JavaDoc namespaceURI,
179                              String JavaDoc qualifiedName,
180                              String JavaDoc value)
181     throws DOMException
182   {
183     try {
184       _delegate.setAttributeNS(namespaceURI, qualifiedName, value);
185     }
186     catch (org.w3c.dom.DOMException JavaDoc ex) {
187       throw wrap(ex);
188     }
189   }
190
191   public DOMAttr setAttributeNode(DOMAttr newAttr)
192     throws DOMException
193   {
194     try {
195       return wrap(_delegate.setAttributeNode(newAttr._delegate));
196     }
197     catch (org.w3c.dom.DOMException JavaDoc ex) {
198       throw wrap(ex);
199     }
200   }
201
202   public DOMAttr setAttributeNodeNS(DOMAttr newAttr)
203     throws DOMException
204   {
205     try {
206       return wrap(_delegate.setAttributeNodeNS(newAttr._delegate));
207     }
208     catch (org.w3c.dom.DOMException JavaDoc ex) {
209       throw wrap(ex);
210     }
211   }
212
213   public void setIdAttribute(String JavaDoc name, boolean isId)
214     throws DOMException
215   {
216     try {
217       _delegate.setIdAttribute(name, isId);
218     }
219     catch (org.w3c.dom.DOMException JavaDoc ex) {
220       throw wrap(ex);
221     }
222   }
223
224   public void setIdAttributeNS(String JavaDoc namespaceURI,
225                                String JavaDoc localName,
226                                boolean isId)
227     throws DOMException
228   {
229     try {
230       _delegate.setIdAttributeNS(namespaceURI, localName, isId);
231     }
232     catch (org.w3c.dom.DOMException JavaDoc ex) {
233       throw wrap(ex);
234     }
235   }
236
237   public void setIdAttributeNode(DOMAttr idAttr, boolean isId)
238     throws DOMException
239   {
240     try {
241       _delegate.setIdAttributeNode(idAttr._delegate, isId);
242     }
243     catch (org.w3c.dom.DOMException JavaDoc ex) {
244       throw wrap(ex);
245     }
246   }
247 }
248
Popular Tags