KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > dom > GenericElement


1 /*
2
3    Copyright 2000 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.dom;
19
20 import org.w3c.dom.DOMException JavaDoc;
21 import org.w3c.dom.Node JavaDoc;
22
23 /**
24  * This class implements the {@link org.w3c.dom.Element} interface.
25  *
26  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
27  * @version $Id: GenericElement.java,v 1.4 2004/08/18 07:13:08 vhardy Exp $
28  */

29 public class GenericElement extends AbstractElement {
30     /**
31      * The node name.
32      */

33     protected String JavaDoc nodeName;
34
35     /**
36      * Is this element immutable?
37      */

38     protected boolean readonly;
39
40     /**
41      * Creates a new Element object.
42      */

43     protected GenericElement() {
44     }
45
46     /**
47      * Creates a new Element object.
48      * @param name The element name for validation purposes.
49      * @param owner The owner document.
50      * @exception DOMException
51      * INVALID_CHARACTER_ERR: if name contains invalid characters,
52      */

53     public GenericElement(String JavaDoc name, AbstractDocument owner)
54     throws DOMException JavaDoc {
55     super(name, owner);
56     nodeName = name;
57     }
58
59     /**
60      * Sets the name of this node.
61      */

62     public void setNodeName(String JavaDoc v) {
63     nodeName = v;
64     }
65
66     /**
67      * <b>DOM</b>: Implements {@link org.w3c.dom.Node#getNodeName()}.
68      * @return {@link #nodeName}
69      */

70     public String JavaDoc getNodeName() {
71     return nodeName;
72     }
73
74     // ExtendedNode //////////////////////////////////////////////////
75

76     /**
77      * Tests whether this node is readonly.
78      */

79     public boolean isReadonly() {
80     return readonly;
81     }
82
83     /**
84      * Sets this node readonly attribute.
85      */

86     public void setReadonly(boolean v) {
87     readonly = v;
88     }
89
90     /**
91      * Exports this node to the given document.
92      */

93     protected Node JavaDoc export(Node JavaDoc n, AbstractDocument d) {
94     super.export(n, d);
95     GenericElement ge = (GenericElement)n;
96     ge.nodeName = nodeName;
97     return n;
98     }
99
100     /**
101      * Deeply exports this node to the given document.
102      */

103     protected Node JavaDoc deepExport(Node JavaDoc n, AbstractDocument d) {
104     super.deepExport(n, d);
105     GenericElement ge = (GenericElement)n;
106     ge.nodeName = nodeName;
107     return n;
108     }
109
110     /**
111      * Copy the fields of the current node into the given node.
112      * @param n a node of the type of this.
113      */

114     protected Node JavaDoc copyInto(Node JavaDoc n) {
115     GenericElement ge = (GenericElement)super.copyInto(n);
116     ge.nodeName = nodeName;
117     return n;
118     }
119
120     /**
121      * Deeply copy the fields of the current node into the given node.
122      * @param n a node of the type of this.
123      */

124     protected Node JavaDoc deepCopyInto(Node JavaDoc n) {
125     GenericElement ge = (GenericElement)super.deepCopyInto(n);
126     ge.nodeName = nodeName;
127     return n;
128     }
129
130     /**
131      * Returns a new uninitialized instance of this object's class.
132      */

133     protected Node JavaDoc newNode() {
134         return new GenericElement();
135     }
136 }
137
Popular Tags