ElementDefinitionImpl.java revision 628:2bfaf29cc90b
1/* 2 * reserved comment block 3 * DO NOT REMOVE OR ALTER! 4 */ 5/* 6 * Copyright 1999-2002,2004 The Apache Software Foundation. 7 * 8 * Licensed under the Apache License, Version 2.0 (the "License"); 9 * you may not use this file except in compliance with the License. 10 * You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 */ 20 21package com.sun.org.apache.xerces.internal.dom; 22 23import org.w3c.dom.NamedNodeMap; 24import org.w3c.dom.Node; 25 26/** 27 * NON-DOM CLASS: Describe one of the Elements (and its associated 28 * Attributes) defined in this Document Type. 29 * <p> 30 * I've included this in Level 1 purely as an anchor point for default 31 * attributes. In Level 2 it should enable the ChildRule support. 32 * 33 * @xerces.internal 34 * 35 */ 36public class ElementDefinitionImpl 37 extends ParentNode { 38 39 // 40 // Constants 41 // 42 43 /** Serialization version. */ 44 static final long serialVersionUID = -8373890672670022714L; 45 46 // 47 // Data 48 // 49 50 /** Element definition name. */ 51 protected String name; 52 53 /** Default attributes. */ 54 protected NamedNodeMapImpl attributes; 55 56 // 57 // Constructors 58 // 59 60 /** Factory constructor. */ 61 public ElementDefinitionImpl(CoreDocumentImpl ownerDocument, String name) { 62 super(ownerDocument); 63 this.name = name; 64 attributes = new NamedNodeMapImpl(ownerDocument); 65 } 66 67 // 68 // Node methods 69 // 70 71 /** 72 * A short integer indicating what type of node this is. The named 73 * constants for this value are defined in the org.w3c.dom.Node interface. 74 */ 75 public short getNodeType() { 76 return NodeImpl.ELEMENT_DEFINITION_NODE; 77 } 78 79 /** 80 * Returns the element definition name 81 */ 82 public String getNodeName() { 83 if (needsSyncData()) { 84 synchronizeData(); 85 } 86 return name; 87 } 88 89 /** 90 * Replicate this object. 91 */ 92 public Node cloneNode(boolean deep) { 93 94 ElementDefinitionImpl newnode = 95 (ElementDefinitionImpl) super.cloneNode(deep); 96 // NamedNodeMap must be explicitly replicated to avoid sharing 97 newnode.attributes = attributes.cloneMap(newnode); 98 return newnode; 99 100 } // cloneNode(boolean):Node 101 102 /** 103 * Query the attributes defined on this Element. 104 * <p> 105 * In the base implementation this Map simply contains Attribute objects 106 * representing the defaults. In a more serious implementation, it would 107 * contain AttributeDefinitionImpl objects for all declared Attributes, 108 * indicating which are Default, DefaultFixed, Implicit and/or Required. 109 * 110 * @return org.w3c.dom.NamedNodeMap containing org.w3c.dom.Attribute 111 */ 112 public NamedNodeMap getAttributes() { 113 114 if (needsSyncChildren()) { 115 synchronizeChildren(); 116 } 117 return attributes; 118 119 } // getAttributes():NamedNodeMap 120 121} // class ElementDefinitionImpl 122