KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > dom > ElementDefinitionImpl


1 /*
2  * Copyright 1999-2002,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of 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,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.xerces.dom;
18
19 import org.w3c.dom.NamedNodeMap JavaDoc;
20 import org.w3c.dom.Node JavaDoc;
21
22 /**
23  * NON-DOM CLASS: Describe one of the Elements (and its associated
24  * Attributes) defined in this Document Type.
25  * <p>
26  * I've included this in Level 1 purely as an anchor point for default
27  * attributes. In Level 2 it should enable the ChildRule support.
28  *
29  * @xerces.internal
30  *
31  * @version $Id: ElementDefinitionImpl.java,v 1.14 2004/10/05 17:12:50 mrglavas Exp $
32  */

33 public class ElementDefinitionImpl
34     extends ParentNode {
35
36     //
37
// Constants
38
//
39

40     /** Serialization version. */
41     static final long serialVersionUID = -8373890672670022714L;
42     
43     //
44
// Data
45
//
46

47     /** Element definition name. */
48     protected String JavaDoc name;
49
50     /** Default attributes. */
51     protected NamedNodeMapImpl attributes;
52
53     //
54
// Constructors
55
//
56

57     /** Factory constructor. */
58     public ElementDefinitionImpl(CoreDocumentImpl ownerDocument, String JavaDoc name) {
59         super(ownerDocument);
60         this.name = name;
61         attributes = new NamedNodeMapImpl(ownerDocument);
62     }
63
64     //
65
// Node methods
66
//
67

68     /**
69      * A short integer indicating what type of node this is. The named
70      * constants for this value are defined in the org.w3c.dom.Node interface.
71      */

72     public short getNodeType() {
73         return NodeImpl.ELEMENT_DEFINITION_NODE;
74     }
75
76     /**
77      * Returns the element definition name
78      */

79     public String JavaDoc getNodeName() {
80         if (needsSyncData()) {
81             synchronizeData();
82         }
83         return name;
84     }
85
86     /**
87      * Replicate this object.
88      */

89     public Node JavaDoc cloneNode(boolean deep) {
90
91         ElementDefinitionImpl newnode =
92             (ElementDefinitionImpl) super.cloneNode(deep);
93         // NamedNodeMap must be explicitly replicated to avoid sharing
94
newnode.attributes = attributes.cloneMap(newnode);
95         return newnode;
96
97     } // cloneNode(boolean):Node
98

99     /**
100      * Query the attributes defined on this Element.
101      * <p>
102      * In the base implementation this Map simply contains Attribute objects
103      * representing the defaults. In a more serious implementation, it would
104      * contain AttributeDefinitionImpl objects for all declared Attributes,
105      * indicating which are Default, DefaultFixed, Implicit and/or Required.
106      *
107      * @return org.w3c.dom.NamedNodeMap containing org.w3c.dom.Attribute
108      */

109     public NamedNodeMap JavaDoc getAttributes() {
110
111         if (needsSyncChildren()) {
112             synchronizeChildren();
113         }
114         return attributes;
115
116     } // getAttributes():NamedNodeMap
117

118 } // class ElementDefinitionImpl
119
Popular Tags