KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > apache > xerces > dom > EntityImpl


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 1999 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Xerces" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation and was
52  * originally based on software copyright (c) 1999, International
53  * Business Machines, Inc., http://www.apache.org. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  */

57
58 package org.enhydra.apache.xerces.dom;
59
60 import org.w3c.dom.Entity JavaDoc;
61 import org.w3c.dom.Node JavaDoc;
62
63 /**
64  * Entity nodes hold the reference data for an XML Entity -- either
65  * parsed or unparsed. The nodeName (inherited from Node) will contain
66  * the name (if any) of the Entity. Its data will be contained in the
67  * Entity's children, in exactly the structure which an
68  * EntityReference to this name will present within the document's
69  * body.
70  * <P>
71  * Note that this object models the actual entity, _not_ the entity
72  * declaration or the entity reference.
73  * <P>
74  * An XML processor may choose to completely expand entities before
75  * the structure model is passed to the DOM; in this case, there will
76  * be no EntityReferences in the DOM tree.
77  * <P>
78  * Quoting the 10/01 DOM Proposal,
79  * <BLOCKQUOTE>
80  * "The DOM Level 1 does not support editing Entity nodes; if a user
81  * wants to make changes to the contents of an Entity, every related
82  * EntityReference node has to be replaced in the structure model by
83  * a clone of the Entity's contents, and then the desired changes
84  * must be made to each of those clones instead. All the
85  * descendants of an Entity node are readonly."
86  * </BLOCKQUOTE>
87  * I'm interpreting this as: It is the parser's responsibilty to call
88  * the non-DOM operation setReadOnly(true,true) after it constructs
89  * the Entity. Since the DOM explicitly decided not to deal with this,
90  * _any_ answer will involve a non-DOM operation, and this is the
91  * simplest solution.
92  *
93  *
94  * @version
95  * @since PR-DOM-Level-1-19980818.
96  */

97 public class EntityImpl
98     extends ParentNode
99     implements Entity JavaDoc {
100
101     //
102
// Constants
103
//
104

105     /** Serialization version. */
106     static final long serialVersionUID = -3575760943444303423L;
107     
108     //
109
// Data
110
//
111

112     /** Entity name. */
113     protected String JavaDoc name;
114
115     /** Public identifier. */
116     protected String JavaDoc publicId;
117
118     /** System identifier. */
119     protected String JavaDoc systemId;
120
121     /** Encoding */
122     protected String JavaDoc encoding;
123
124     /** Version */
125     protected String JavaDoc version;
126
127
128     /** Notation name. */
129     protected String JavaDoc notationName;
130
131     //
132
// Constructors
133
//
134

135     /** Factory constructor. */
136     public EntityImpl(CoreDocumentImpl ownerDoc, String JavaDoc name) {
137         super(ownerDoc);
138         this.name = name;
139         isReadOnly(true);
140     }
141     
142     //
143
// Node methods
144
//
145

146     /**
147      * A short integer indicating what type of node this is. The named
148      * constants for this value are defined in the org.w3c.dom.Node interface.
149      */

150     public short getNodeType() {
151         return Node.ENTITY_NODE;
152     }
153
154     /**
155      * Returns the entity name
156      */

157     public String JavaDoc getNodeName() {
158         if (needsSyncData()) {
159             synchronizeData();
160         }
161         return name;
162     }
163
164     /** Clone node. */
165     public Node JavaDoc cloneNode(boolean deep) {
166         EntityImpl newentity = (EntityImpl)super.cloneNode(deep);
167         return newentity;
168     }
169
170     //
171
// Entity methods
172
//
173

174     /**
175      * The public identifier associated with the entity. If not specified,
176      * this will be null.
177      */

178     public String JavaDoc getPublicId() {
179         
180         if (needsSyncData()) {
181             synchronizeData();
182         }
183         return publicId;
184
185     } // getPublicId():String
186

187     /**
188      * The system identifier associated with the entity. If not specified,
189      * this will be null.
190      */

191     public String JavaDoc getSystemId() {
192
193         if (needsSyncData()) {
194             synchronizeData();
195         }
196         return systemId;
197
198     } // getSystemId():String
199

200     /**
201       * DOM Level 3 WD - experimental
202       * the version number of this entity, when it is an external parsed entity.
203       */

204     public String JavaDoc getVersion() {
205
206        if (needsSyncData()) {
207            synchronizeData();
208        }
209        return version;
210
211    } // getVersion():String
212

213
214     /**
215      * DOM Level 3 WD - experimental
216      * the encoding of this entity, when it is an external parsed entity.
217      */

218     public String JavaDoc getEncoding() {
219
220        if (needsSyncData()) {
221            synchronizeData();
222        }
223        return encoding;
224
225    } // getVersion():String
226

227
228
229
230
231     /**
232      * Unparsed entities -- which contain non-XML data -- have a
233      * "notation name" which tells applications how to deal with them.
234      * Parsed entities, which <em>are</em> in XML format, don't need this and
235      * set it to null.
236      */

237     public String JavaDoc getNotationName() {
238
239         if (needsSyncData()) {
240             synchronizeData();
241         }
242         return notationName;
243
244     } // getNotationName():String
245

246     //
247
// Public methods
248
//
249

250     /**
251      * DOM Level 2: The public identifier associated with the entity. If not specified,
252      * this will be null. */

253     public void setPublicId(String JavaDoc id) {
254         
255         if (needsSyncData()) {
256             synchronizeData();
257         }
258         publicId = id;
259
260     } // setPublicId(String)
261

262     /**
263      * DOM Level 3 WD - experimental
264      * encoding - An attribute specifying, as part of the text declaration,
265      * the encoding of this entity, when it is an external parsed entity.
266      * This is null otherwise
267      */

268     public void setEncoding(String JavaDoc value) {
269         
270         if (needsSyncData()) {
271             synchronizeData();
272         }
273         encoding = value;
274
275     } // setEncoding (String)
276

277
278     /**
279       * DOM Level 3 WD - experimental
280       * version - An attribute specifying, as part of the text declaration,
281       * the version number of this entity, when it is an external parsed entity.
282       * This is null otherwise
283       */

284     public void setVersion(String JavaDoc value) {
285         
286         if (needsSyncData()) {
287             synchronizeData();
288         }
289         version = value;
290
291     } // setVersion (String)
292

293
294     /**
295      * DOM Level 2: The system identifier associated with the entity. If not
296      * specified, this will be null.
297      */

298     public void setSystemId(String JavaDoc id) {
299
300         if (needsSyncData()) {
301             synchronizeData();
302         }
303         systemId = id;
304
305     } // setSystemId(String)
306

307     /**
308      * DOM Level 2: Unparsed entities -- which contain non-XML data -- have a
309      * "notation name" which tells applications how to deal with them.
310      * Parsed entities, which <em>are</em> in XML format, don't need this and
311      * set it to null.
312      */

313     public void setNotationName(String JavaDoc name) {
314         
315         if (needsSyncData()) {
316             synchronizeData();
317         }
318         notationName = name;
319
320     } // setNotationName(String)
321

322
323     /* (non-Javadoc)
324      * @see org.w3c.dom.Entity#getInputEncoding()
325      */

326     public String JavaDoc getInputEncoding() {
327         // TODO Auto-generated method stub
328
return null;
329     }
330     /* (non-Javadoc)
331      * @see org.w3c.dom.Entity#getXmlEncoding()
332      */

333     public String JavaDoc getXmlEncoding() {
334         // TODO Auto-generated method stub
335
return null;
336     }
337     /* (non-Javadoc)
338      * @see org.w3c.dom.Entity#getXmlVersion()
339      */

340     public String JavaDoc getXmlVersion() {
341         // TODO Auto-generated method stub
342
return null;
343     }
344
345 } // class EntityImpl
346
Popular Tags