KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > xml > dom > ElementDeclImpl


1 /**
2  * org/ozone-db/xml/dom/ElementDeclImpl.java
3  *
4  * The contents of this file are subject to the OpenXML Public
5  * License Version 1.0; you may not use this file except in compliance
6  * with the License. You may obtain a copy of the License at
7  * http://www.openxml.org/license.html
8  *
9  * THIS SOFTWARE IS DISTRIBUTED ON AN "AS IS" BASIS WITHOUT WARRANTY
10  * OF ANY KIND, EITHER EXPRESSED OR IMPLIED. THE INITIAL DEVELOPER
11  * AND ALL CONTRIBUTORS SHALL NOT BE LIABLE FOR ANY DAMAGES AS A
12  * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
13  * DERIVATIVES. SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING
14  * RIGHTS AND LIMITATIONS UNDER THE LICENSE.
15  *
16  * The Initial Developer of this code under the License is Assaf Arkin.
17  * Portions created by Assaf Arkin are Copyright (C) 1998, 1999.
18  * All Rights Reserved.
19  */

20
21 /**
22  * Changes for Persistent DOM running with ozone are
23  * Copyright 1999 by SMB GmbH. All rights reserved.
24  */

25
26 package org.ozoneDB.xml.dom;
27
28 import org.w3c.dom.*;
29
30
31 /**
32  * @version $Revision: 1.2 $ $Date: 2003/11/20 23:18:42 $
33  * @author <a HREF="mailto:arkin@trendline.co.il">Assaf Arkin</a>
34  * @see org.w3c.dom.Node
35  * @see NodeImpl
36  */

37 public class ElementDeclImpl extends NodeImpl implements ElementDeclProxy {
38
39     final static long serialVersionUID = 1;
40
41
42     public short getNodeType() {
43         return ELEMENT_DECL_NODE;
44     }
45
46
47     public String JavaDoc getName() {
48         return getNodeName();
49     }
50
51
52     public synchronized boolean equals( Object JavaDoc other ) {
53         /*
54         EntityProxy otherX;
55
56         // Test for node equality (this covers entity name and all its children)
57         // and then test for specific entity qualities.
58         if (super.equals (other)) {
59             otherX = (EntityProxy) other;
60             return (getPublicId ().equals (otherX.getPublicId ()) &&
61                     getSystemId ().equals (otherX.getSystemId ()) &&
62                     getNotation ().equals (otherX.getNotation ()));
63             }
64          */

65         return false;
66     }
67
68
69     /**
70      * Returns true if element is empty. An empty element cannot contain any
71      * children and must be specified with an empty tag, or an opening tag
72      * immediately followed by a closing tag.
73      *
74      * @return True if element is empty
75      */

76     public boolean isEmpty() {
77         return _empty;
78     }
79
80
81     /**
82      * Returns true if element may contain any child elements and character data
83      * in any order.
84      *
85      * @return True if element supports any contents
86      */

87     public boolean isAny() {
88         return _any;
89     }
90
91
92     /**
93      * Returns true if element contains mixed contents. Mixed contents includes
94      * both elements and character data in any particular order. This option
95      * implies that both {@link #isEmpty} and {@link #isAny} return false.
96      * If all three are false, then contents is subject to exact order.
97      *
98      * @return True if element contains mixed contents
99      */

100     public boolean isMixed() {
101         return _mixed;
102     }
103
104
105     /**
106      * Returns true if the opening tag is optional. Even if the opening tag is
107      * missing from the document for this element, the document is still valid.
108      * This option only relates to HTML document, and implies that {@link
109      * #requiresClosingTag} is also true.
110      *
111      * @return True if opening tag is optional
112      */

113     public boolean requiresOpeningTag() {
114         return _optionalOpen;
115     }
116
117
118     /**
119      * Returns true if the closing tag is optional. Even if the closing tag is
120      * missing from the document for this element, the document is still valid.
121      * This option only relates to HTML document.
122      *
123      * @return True if closing tag is optional
124      */

125     public boolean requiresClosingTag() {
126         return _optionalClose;
127     }
128
129
130     public final Object JavaDoc clone() {
131         ElementDeclProxy clone = null;
132         try {
133             clone = (ElementDeclProxy)database().createObject( ElementDeclImpl.class.getName() );
134             (clone).init( _ownerDocument, getNodeName(), null, true );
135             cloneInto( clone, true );
136         } catch (Exception JavaDoc except) {
137             throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );
138         }
139         return clone;
140     }
141
142
143     public final Node cloneNode( boolean deep ) {
144         ElementDeclProxy clone = null;
145         try {
146             clone = (ElementDeclProxy)database().createObject( ElementDeclImpl.class.getName() );
147             (clone).init( _ownerDocument, getNodeName(), null, true );
148             cloneInto( clone, deep );
149         } catch (Exception JavaDoc except) {
150             throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );
151         }
152         return clone;
153     }
154
155
156     /**
157      * Constructor requires owner document, element name and its definition.
158      *
159      * @param owner The owner document
160      * @param name The element name
161      * @param definition The element definition
162      */

163     ElementDeclImpl( DocumentImpl owner, String JavaDoc name, String JavaDoc definition ) {
164         this( owner, name, definition, false, false );
165     }
166
167
168     /**
169      * Constructor requires owner document, element name and its definition.
170      * The flags for optional opening and closing tag are supported only for
171      * HTML documents.
172      *
173      * @param owner The owner document
174      * @param name The element name
175      * @param definition The element definition
176      * @param optionalOpen The opening tag is optional
177      * @param optionalClose The closing tag is optional
178      */

179     ElementDeclImpl( DocumentImpl owner, String JavaDoc name, String JavaDoc definition, boolean optionalOpen, boolean optionalClose ) {
180         super( owner, name, null, true );
181         _optionalOpen = optionalOpen;
182         if (_optionalOpen) {
183             _optionalClose = true;
184         } else {
185             _optionalClose = optionalClose;
186         }
187         if (definition.equals( "EMPTY" )) {
188             _empty = true;
189         } else if (definition.equals( "ANY" )) {
190             _any = true;
191         } else {
192         }
193     }
194
195
196     private ElementDeclImpl( DocumentImpl owner, String JavaDoc name ) {
197         super( owner, name, null, true );
198     }
199
200     /**
201      * Indicates that the opening tag is optional: even if missing from the
202      * document, the document is still valid. Applies only to HTML documents.
203      * Also implies that {@link #_optionalClose} is true.
204      */

205     private boolean _optionalOpen;
206
207
208     /**
209      * Indicates that the closing tag is optional: even if missing from the
210      * document, the document is still valid. Applies only to HTML documents.
211      */

212     private boolean _optionalClose;
213
214
215     /**
216      * Indicates that the element is empty.
217      */

218     private boolean _empty;
219
220
221     /**
222      * Indicates that the element can contain any child elements of any type
223      * and any order.
224      */

225     private boolean _any;
226
227
228     /**
229      * Indicates that the element contains mixed contents. Mixed contents
230      * includes both elements and character data in any particular order.
231      */

232     private boolean _mixed;
233 }
234
Popular Tags